Commit 9a50ed75 authored by Steve Goering's avatar Steve Goering

small refactoring of modules to commands, and update readme file

parent f6ea8ff7
{
"moduls_directory": "tools/",
"commands_directory": "tools/",
"allowed_scripts": ["python", "bash"],
"ignored_dirs": ["CVS"],
"update": "core/update.sh",
"version": "core/version.sh"
"version": "core/version.sh",
"commands_help": {
"core" :"Core functions of webis command.",
}
}
\ No newline at end of file
......@@ -8,7 +8,7 @@ authors:
About
-----
webis is a command wrapping toolkit
"webis" is a command wrapping toolkit
Requirements
------------
......@@ -16,22 +16,23 @@ python3, pep8
Usage
-----
for first starts run:
For first starts run:
> $./webis.py -h
Configuration
-------------
see: config.json
See: config.json
```
{
"moduls_directory": "tools/",
"commands_directory": "tools/",
"allowed_scripts": ["python", "bash"],
"ignored_dirs": ["CVS"]
"ignored_dirs": ["CVS"],
....
}
```
Modules directory (tools)
Commands directory (tools)
-------------------------
e.g.:
├── core
......@@ -44,9 +45,8 @@ e.g.:
├── t.oy
└── t.txt
core and test are metanames for each toolkit
a call
>$./webis.py core help
"core" and "test" are metanames for each toolkit, a call
>$./webis.py core -h
will print a short summary of all tools
......@@ -54,30 +54,39 @@ will print a short summary of all tools
will perform a code style check of the tools directory
Adding a new Module
Adding a new Command
-------------------
first create a new folder in the "moduls_directory" with name FOLDER
add all scrips to this folder, e.g. MYSCRIPT.py
check if
First create a new folder in the "commandss_directory" with name FOLDER add all scrips to this folder,
e.g. MYSCRIPT.py and check if
>$./webis.py FOLDER MYSCRIPT
works
>$./webis.py FOLDER -h
>$./webis.py -h
works.
Add in config.json the general description of the command in the "commands_help" part.
### Notes for MYSCRIPT
inside a new module directory, every script should have a small description comment
e.g.:
Inside a new command directory, every script should have a small description comment, e.g.:
```
#!/bin/bash
# NICE DESCRIPTION
ls /
```
it is important for the './webis.py NAME help' call that this comment is the second line of the script, this approach can be seen as a extension of shebang
It is important for the './webis.py NAME -h' call that this comment is the second line of the script, this approach can be seen as a extension of shebang.
### General scripts
All scripts must be code style checked with the "webis code checker" command. For python scripts this checks pep8 code style and for bash it checks the google bash style conventions.
### Bash scripts
use bashhelper functions (logError, ...) for output (see install for including)
Use bashhelper functions (logError, ...) for output (see install for including).
### Python scripts
use lib, log, system in "lib" directory for uniform outputs and reducing reinventing the wheel
Use lib, log, system in "lib" directory for uniform outputs and reducing reinventing the wheel.
Organize imports of each python script in the following way:
1. python standard libraries
2. thirdparty imports
3. own imports
Possible problems with new modules
----------------------------------
......
......@@ -31,12 +31,10 @@ def load_config():
def get_commands(config):
"""Returns commands mapped to directories containing their subcommands."""
commands = collections.OrderedDict()
# FIXME: Variable names should be English only; also "moduls" has been
# renamed to "command".
for directory in os.listdir(config["moduls_directory"]):
if (os.path.isdir(config["moduls_directory"] + directory) and
for directory in os.listdir(config["commands_directory"]):
if (os.path.isdir(config["commands_directory"] + directory) and
directory not in config["ignored_dirs"]):
commands[directory] = config["moduls_directory"] + directory
commands[directory] = config["commands_directory"] + directory
return commands
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment