Using python3-docopt to process command-line arguments.
Lost the color and result statuses in the command-line help, but should be able to get them back.
This commit is contained in:
parent
454510f181
commit
fee10f1343
3 changed files with 31 additions and 27 deletions
|
|
@ -12,9 +12,14 @@
|
||||||
│The reports are cached in a directory[0m[38;2;255;255;255m[48;2;100;100;100m [0m[38;2;255;255;255m[48;2;0;0;0m│
|
│The reports are cached in a directory[0m[38;2;255;255;255m[48;2;100;100;100m [0m[38;2;255;255;255m[48;2;0;0;0m│
|
||||||
│ [0m[38;2;255;255;255m[48;2;100;100;100m [0m[38;2;255;255;255m[48;2;0;0;0m│
|
│ [0m[38;2;255;255;255m[48;2;100;100;100m [0m[38;2;255;255;255m[48;2;0;0;0m│
|
||||||
│ [0m[38;2;255;255;255m[48;2;100;100;100m [0m[38;2;255;255;255m[48;2;0;0;0m│
|
│ [0m[38;2;255;255;255m[48;2;100;100;100m [0m[38;2;255;255;255m[48;2;0;0;0m│
|
||||||
│Usage: vigil <root_path> [0m[38;2;255;255;255m[48;2;100;100;100m [0m[38;2;255;255;255m[48;2;0;0;0m│
|
│Usage: [0m[38;2;255;255;255m[48;2;100;100;100m [0m[38;2;255;255;255m[48;2;0;0;0m│
|
||||||
|
│ vigil <root_path> [0m[38;2;255;255;255m[48;2;100;100;100m [0m[38;2;255;255;255m[48;2;0;0;0m│
|
||||||
│ [0m[38;2;255;255;255m[48;2;100;100;100m [0m[38;2;255;255;255m[48;2;0;0;0m│
|
│ [0m[38;2;255;255;255m[48;2;100;100;100m [0m[38;2;255;255;255m[48;2;0;0;0m│
|
||||||
│e.g. # vigil my_project [0m[38;2;255;255;255m[48;2;100;100;100m [0m[38;2;255;255;255m[48;2;0;0;0m│
|
│Example: [0m[38;2;255;255;255m[48;2;100;100;100m [0m[38;2;255;255;255m[48;2;0;0;0m│
|
||||||
|
│ # vigil my_project [0m[38;2;255;255;255m[48;2;100;100;100m [0m[38;2;255;255;255m[48;2;0;0;0m│
|
||||||
|
│ [0m[38;2;255;255;255m[48;2;100;100;100m [0m[38;2;255;255;255m[48;2;0;0;0m│
|
||||||
|
│Options: [0m[38;2;255;255;255m[48;2;100;100;100m [0m[38;2;255;255;255m[48;2;0;0;0m│
|
||||||
|
│ -h, --help Show this screen and ex[0m[38;2;255;255;255m[48;2;100;100;100m [0m[38;2;255;255;255m[48;2;0;0;0m│
|
||||||
│ [0m[38;2;255;255;255m[48;2;100;100;100m [0m[38;2;255;255;255m[48;2;0;0;0m│
|
│ [0m[38;2;255;255;255m[48;2;100;100;100m [0m[38;2;255;255;255m[48;2;0;0;0m│
|
||||||
│Keys: [0m[38;2;255;255;255m[48;2;100;100;100m [0m[38;2;255;255;255m[48;2;0;0;0m│
|
│Keys: [0m[38;2;255;255;255m[48;2;100;100;100m [0m[38;2;255;255;255m[48;2;0;0;0m│
|
||||||
│ [0m[38;2;0;255;0m[48;2;0;0;0mh[0m[38;2;255;255;255m[48;2;0;0;0m - Show the help screen. (toggle) [0m[38;2;255;255;255m[48;2;100;100;100m [0m[38;2;255;255;255m[48;2;0;0;0m│
|
│ [0m[38;2;0;255;0m[48;2;0;0;0mh[0m[38;2;255;255;255m[48;2;0;0;0m - Show the help screen. (toggle) [0m[38;2;255;255;255m[48;2;100;100;100m [0m[38;2;255;255;255m[48;2;0;0;0m│
|
||||||
|
|
@ -24,17 +29,12 @@
|
||||||
│ [0m[38;2;0;255;0m[48;2;0;0;0mt[0m[38;2;255;255;255m[48;2;0;0;0m - Turn the result pane to portrai[0m[38;2;255;255;255m[48;2;100;100;100m [0m[38;2;255;255;255m[48;2;0;0;0m│
|
│ [0m[38;2;0;255;0m[48;2;0;0;0mt[0m[38;2;255;255;255m[48;2;0;0;0m - Turn the result pane to portrai[0m[38;2;255;255;255m[48;2;100;100;100m [0m[38;2;255;255;255m[48;2;0;0;0m│
|
||||||
│ [0m[38;2;0;255;0m[48;2;0;0;0ml[0m[38;2;255;255;255m[48;2;0;0;0m - Show the activity log. (toggle)[0m[38;2;255;255;255m[48;2;100;100;100m [0m[38;2;255;255;255m[48;2;0;0;0m│
|
│ [0m[38;2;0;255;0m[48;2;0;0;0ml[0m[38;2;255;255;255m[48;2;0;0;0m - Show the activity log. (toggle)[0m[38;2;255;255;255m[48;2;100;100;100m [0m[38;2;255;255;255m[48;2;0;0;0m│
|
||||||
│ [0m[38;2;0;255;0m[48;2;0;0;0mn[0m[38;2;255;255;255m[48;2;0;0;0m - Move to the next issue. [0m[38;2;255;255;255m[48;2;100;100;100m [0m[38;2;255;255;255m[48;2;0;0;0m│
|
│ [0m[38;2;0;255;0m[48;2;0;0;0mn[0m[38;2;255;255;255m[48;2;0;0;0m - Move to the next issue. [0m[38;2;255;255;255m[48;2;100;100;100m [0m[38;2;255;255;255m[48;2;0;0;0m│
|
||||||
│ [0m[38;2;0;255;0m[48;2;0;0;0mN[0m[38;2;255;255;255m[48;2;0;0;0m - Move to the next issue of the c[0m[38;2;255;255;255m[48;2;100;100;100m [0m[38;2;255;255;255m[48;2;0;0;0m│
|
│ [0m[38;2;0;255;0m[48;2;0;0;0mN[0m[38;2;255;255;255m[48;2;0;0;0m - Move to the next issue of the c │
|
||||||
│ [0m[38;2;0;255;0m[48;2;0;0;0mo[0m[38;2;255;255;255m[48;2;0;0;0m - Order files by type, or by dire[0m[38;2;255;255;255m[48;2;100;100;100m [0m[38;2;255;255;255m[48;2;0;0;0m│
|
│ [0m[38;2;0;255;0m[48;2;0;0;0mo[0m[38;2;255;255;255m[48;2;0;0;0m - Order files by type, or by dire │
|
||||||
│ [0m[38;2;0;255;0m[48;2;0;0;0mp[0m[38;2;255;255;255m[48;2;0;0;0m - Pause work. (toggle) [0m[38;2;255;255;255m[48;2;100;100;100m [0m[38;2;255;255;255m[48;2;0;0;0m│
|
│ [0m[38;2;0;255;0m[48;2;0;0;0mp[0m[38;2;255;255;255m[48;2;0;0;0m - Pause work. (toggle) │
|
||||||
│ [0m[38;2;0;255;0m[48;2;0;0;0ms[0m[38;2;255;255;255m[48;2;0;0;0m - Change the appearance of result[0m[38;2;255;255;255m[48;2;100;100;100m [0m[38;2;255;255;255m[48;2;0;0;0m│
|
│ [0m[38;2;0;255;0m[48;2;0;0;0ms[0m[38;2;255;255;255m[48;2;0;0;0m - Change the appearance of result │
|
||||||
│ [0m[38;2;0;255;0m[48;2;0;0;0mq[0m[38;2;255;255;255m[48;2;0;0;0m - Quit. [0m[38;2;255;255;255m[48;2;100;100;100m [0m[38;2;255;255;255m[48;2;0;0;0m│
|
│ [0m[38;2;0;255;0m[48;2;0;0;0mq[0m[38;2;255;255;255m[48;2;0;0;0m - Quit. │
|
||||||
│ [0m[38;2;255;255;255m[48;2;100;100;100m [0m[38;2;255;255;255m[48;2;0;0;0m│
|
│ │
|
||||||
│Statuses: [0m[38;2;255;255;255m[48;2;100;100;100m [0m[38;2;255;255;255m[48;2;0;0;0m│
|
│Statuses: │
|
||||||
│ Normal [0m[38;2;255;255;255m[48;2;100;100;100m [0m[38;2;255;255;255m[48;2;0;0;0m│
|
|
||||||
│ [0m[38;2;0;255;0m[48;2;0;0;0m [0m[38;2;255;255;255m[48;2;0;0;0m Ok [0m[38;2;255;255;255m[48;2;100;100;100m [0m[38;2;255;255;255m[48;2;0;0;0m│
|
|
||||||
│ [0m[38;2;255;0;0m[48;2;0;0;0m [0m[38;2;255;255;255m[48;2;0;0;0m Problem │
|
|
||||||
│ [0m[38;2;100;100;100m[48;2;0;0;0m [0m[38;2;255;255;255m[48;2;0;0;0m Not applicable │
|
|
||||||
│ [0m[38;2;90;90;255m[48;2;0;0;0m [0m[38;2;255;255;255m[48;2;0;0;0m Running │
|
|
||||||
│[0m[38;2;255;255;255m[48;2;100;100;100m [0m[38;2;255;255;255m[48;2;0;0;0m │
|
│[0m[38;2;255;255;255m[48;2;100;100;100m [0m[38;2;255;255;255m[48;2;0;0;0m │
|
||||||
└──────────────────────────────────────┘[0m
|
└──────────────────────────────────────┘[0m
|
||||||
|
|
@ -6,7 +6,7 @@ set -e
|
||||||
|
|
||||||
echo "Install the dependencies of the vigil script..."
|
echo "Install the dependencies of the vigil script..."
|
||||||
sudo apt-get --yes install python3-minimal python3-pygments python3-pyinotify \
|
sudo apt-get --yes install python3-minimal python3-pygments python3-pyinotify \
|
||||||
python3-urwid python3-psutil
|
python3-urwid python3-psutil python3-docopt
|
||||||
echo
|
echo
|
||||||
echo "Install all the tools vigil may need..."
|
echo "Install all the tools vigil may need..."
|
||||||
./install-tools
|
./install-tools
|
||||||
|
|
|
||||||
28
vigil
28
vigil
|
|
@ -18,9 +18,14 @@ to date.
|
||||||
The reports are cached in a directory ".vigil" under the target directory.
|
The reports are cached in a directory ".vigil" under the target directory.
|
||||||
|
|
||||||
|
|
||||||
Usage: vigil <root_path>
|
Usage:
|
||||||
|
vigil <root_path>
|
||||||
|
|
||||||
e.g. # vigil my_project
|
Example:
|
||||||
|
# vigil my_project
|
||||||
|
|
||||||
|
Options:
|
||||||
|
-h, --help Show this screen and exit.
|
||||||
|
|
||||||
Keys:
|
Keys:
|
||||||
*h - Show the help screen. (toggle)
|
*h - Show the help screen. (toggle)
|
||||||
|
|
@ -55,6 +60,7 @@ import threading
|
||||||
import time
|
import time
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
|
import docopt
|
||||||
import pyinotify
|
import pyinotify
|
||||||
|
|
||||||
import fill3
|
import fill3
|
||||||
|
|
@ -1055,13 +1061,11 @@ def manage_cache(root_path):
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
if len(sys.argv) == 2:
|
arguments = docopt.docopt(__doc__.replace("*", ""))
|
||||||
subprocess.call(["sudo", "-p", "Vigil needs sudo to create the filesy"
|
root_path = os.path.abspath(arguments["<root_path>"])
|
||||||
"stem sandbox... [sudo] password for %u: ", "true"])
|
subprocess.call(["sudo", "-p", "Vigil needs sudo to create the filesy"
|
||||||
root_path = os.path.abspath(sys.argv[1])
|
"stem sandbox... [sudo] password for %u: ", "true"])
|
||||||
with terminal.console_title("vigil: " + os.path.basename(root_path)):
|
with terminal.console_title("vigil: " + os.path.basename(root_path)):
|
||||||
manage_cache(root_path)
|
manage_cache(root_path)
|
||||||
with chdir(root_path): # FIX: Don't change directory if possible.
|
with chdir(root_path): # FIX: Don't change directory if possible.
|
||||||
main(root_path)
|
main(root_path)
|
||||||
else:
|
|
||||||
print(_get_help_text())
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue