From c791c19d8f981757695de2d648f4b2c61fcd78bd Mon Sep 17 00:00:00 2001 From: Fred Date: Sat, 18 May 2013 20:00:18 +0800 Subject: [PATCH] Scripts can be listed in the run command --- extra/bash_completion | 2 +- lib/commands/run.py | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/extra/bash_completion b/extra/bash_completion index 3131bed..f5d5ae0 100644 --- a/extra/bash_completion +++ b/extra/bash_completion @@ -176,7 +176,7 @@ function _moodle() { if [[ "${COMP_CWORD}" == 2 ]]; then OPTS="$(_list_scripts)" elif [[ "${COMP_CWORD}" == 3 ]]; then - OPTS="--integration --stable --all $($BIN info -ln)" + OPTS="--integration --stable --all --list $($BIN info -ln)" fi ;; update) diff --git a/lib/commands/run.py b/lib/commands/run.py index 52ec812..f172e1d 100644 --- a/lib/commands/run.py +++ b/lib/commands/run.py @@ -24,12 +24,21 @@ http://github.com/FMCorz/mdk import logging from lib.command import Command +from lib.scripts import Scripts class RunCommand(Command): _arguments = [ ( + ['-l', '--list'], + { + 'action': 'store_true', + 'dest': 'list', + 'help': 'list the available scripts' + } + ), + ( ['-a', '--all'], { 'action': 'store_true', @@ -56,6 +65,7 @@ class RunCommand(Command): ( ['script'], { + 'nargs': '?', 'help': 'the name of the script to run' } ), @@ -71,6 +81,13 @@ class RunCommand(Command): def run(self, args): + # Printing existing scripts + if args.list: + scripts = Scripts.list() + for script in sorted(scripts.keys()): + print u'%s (%s)' % (script, scripts[script]) + return + # Resolving instances names = args.names if args.all: -- 2.11.0