-
Notifications
You must be signed in to change notification settings - Fork 0
CLI
Catbot CLI is a command line interface for Catbot. It allows you to interact with Catbot from the terminal from any location on a Raspberry PI(the Dev environment has to be executed at the root repository see detail below).
- install NodeJS
To use the CLI, simply run the following command in the terminal:
catbotDisplays help information about the CLI.
Runs the main program in Raspberry Pi.
optional arguments:
-
-D,-dev- Boolean - Runs the program in the current repo instead of the globally installed file. example:catbot start -Dwill result to running./src/raspi/main.pyinstead of/opt/catbot/src/raspi/main.py -
-p,-proj- String - Path to the project folder. Defaults tosrc. example:catbot start -p Baby-inatorwill result to runningBaby-inator/raspi/main.pyinstead ofsrc/raspi/main.py -
-f,-file- String - Path to the file containing the code to run. Defaults toraspi/mainforsrc/raspi/main.py. example:catbot start -f Landslideinatorwill result to runningsrc/raspi/Landslideinator.py
TL;DR: path is defined as {-D}/{-p}/{-f}.py default is {"/opt/catbot"}/{"src"}/{"raspi/main"}.py
Runs a sample program in Raspberry Pi. Note that some of the sample files will not run as expected due to Pythonpath this command will ensure that proper execution is done every time and will prevent you from writing import statements differently from other members.
Required arguments:
-
file- String - The name of the file containing the sample code to run. example:catbot sample dummySampleFilewill result in running./src/raspi/sample/dummySampleFile.py
Optional arguments:
-
-D,-dev- Boolean - Runs the program in the current repo instead of the globally installed file. example:catbot sample dummySampleFile -Dwill result to running./src/raspi/sample/dummySampleFile.pyinstead of/opt/catbot/src/raspi/sample/dummySampleFile.py
This is only for devs to deploy the command for other members of the team. Catbot repo is made in a way such that anyone in the team can easily run Catbot CLI without needing to set up any environment. However, to do so, we need to bring the src folder outside of the user directory. ./src -> /opt/catbot/src This is done by running the following command in the root directory of the repo during the post-install script:
sudo npm install -gNote
You must have sudo permission and npm installed in your system. This also means that whenever you update the code, you need to run this command again to update the code to run for other members. Think of this > action as publishing that certain version of the code for other members.
Because of this globally installed script system whatever we write in the repo's src folder will not be run by other users unless we run the npm install command.
But what if we want to test our code in the repo? We can use the -D or -dev argument to run the code in the current directory.
catbot start -DThis will run the code in the repo instead of the globally installed code and will not require the npm install command. You can also add the file argument to run a specific file in the repo.
catbot start -D -f destruct-inatorruns ./src/destruct-inator.py instead of ./src/raspi/main.py
This cli also supports running code from the sister repository Catbot-tools where the file structure is a little bit different from this repo. Tools file structure looks something like this
.
├── Shrink-inator
│ ├── raspi
│ │ ├── main.py
│ │ └── ...
│ ├── arduino
│ │ ├── arduino.ino
│ │ └── ...
│ └── ...
├── DePandainator
│ ├── raspi
│ │ ├── main.py
│ │ └── ...
│ └── ...
└── ...
Which replaces our src folder with a named folder for each project. This is where the -p or -proj argument comes in.
catbot start -D -p Shrink-inatorThis will run the code in ./Shrink-inator/raspi/main.py instead of ./src/raspi/main.py. Note the -D argument is required to run code in the other repo.