mirror of
https://github.com/lucaspalomodevelop/autom.git
synced 2026-03-12 23:27:21 +00:00
added ls command for listing all scripts
This commit is contained in:
parent
c5ebf9637e
commit
a90518816a
2
makefile
2
makefile
@ -1,5 +1,5 @@
|
|||||||
CC = g++
|
CC = g++
|
||||||
CFLAGS = -std=c++11 -Wall
|
CFLAGS = -std=c++17 -Wall
|
||||||
SRCDIR = ./src
|
SRCDIR = ./src
|
||||||
BINDIR = ./bin
|
BINDIR = ./bin
|
||||||
|
|
||||||
|
|||||||
14
src/main.cpp
14
src/main.cpp
@ -13,7 +13,7 @@ int main(int argc, char *argv[])
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// input function for parsing arguments and creating commands and running them
|
// input function for parsing arguments and creating commands and running them
|
||||||
void input(int argc, char *argv[])
|
void input(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
InputParser input(argc, argv);
|
InputParser input(argc, argv);
|
||||||
@ -21,6 +21,7 @@ void input(int argc, char *argv[])
|
|||||||
|
|
||||||
command.addCommand("run", runScript);
|
command.addCommand("run", runScript);
|
||||||
command.addCommand("help", help);
|
command.addCommand("help", help);
|
||||||
|
command.addCommand("ls", listScripts);
|
||||||
command.addDefaultCommand(runScript);
|
command.addDefaultCommand(runScript);
|
||||||
command.runCommand(argv[1], argc, argv);
|
command.runCommand(argv[1], argc, argv);
|
||||||
}
|
}
|
||||||
@ -36,6 +37,17 @@ void runScript(int argc, char *argv[])
|
|||||||
system(script.c_str());
|
system(script.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// list all scripts in the autom directory
|
||||||
|
void listScripts(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
std::cout << "Scripts:" << std::endl;
|
||||||
|
for (const auto &entry : std::filesystem::directory_iterator(dir))
|
||||||
|
{
|
||||||
|
std::string name = entry.path().filename().string();
|
||||||
|
std::cout << " " << name << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// help function for showing help message
|
// help function for showing help message
|
||||||
void help(int argc, char *argv[])
|
void help(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
|||||||
@ -2,6 +2,8 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
#include <filesystem>
|
||||||
|
|
||||||
#include "inputparser.h"
|
#include "inputparser.h"
|
||||||
#include "command.h"
|
#include "command.h"
|
||||||
|
|
||||||
@ -19,9 +21,11 @@ std::string dir = home + "/autom";
|
|||||||
// input function for parsing arguments and creating commands and running them
|
// input function for parsing arguments and creating commands and running them
|
||||||
void input(int argc, char *argv[]);
|
void input(int argc, char *argv[]);
|
||||||
// run a script with is in the autom directory
|
// run a script with is in the autom directory
|
||||||
void runScript(int argc,char *argv[]);
|
void runScript(int argc, char *argv[]);
|
||||||
|
// list all scripts in the autom directory
|
||||||
|
void listScripts(int argc, char *argv[]);
|
||||||
// help function for showing help message
|
// help function for showing help message
|
||||||
void help(int argc,char *argv[]);
|
void help(int argc, char *argv[]);
|
||||||
// void create(int argc,char *argv[]);
|
// void create(int argc,char *argv[]);
|
||||||
// void remove(int argc,char *argv[]);
|
// void remove(int argc,char *argv[]);
|
||||||
// void list(int argc,char *argv[]);
|
// void list(int argc,char *argv[]);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user