From e18be49d2739809a619626f8ddb51ce3f1838a19 Mon Sep 17 00:00:00 2001 From: kaliko Date: Sun, 15 Feb 2015 12:26:57 +0100 Subject: [PATCH] Some cleanup, CLI/bash completion/Doc improvements --- data/bash/completion.sh | 9 +++++---- doc/examples/all_settings.cfg | 3 +-- sima/launch.py | 5 ++--- sima/lib/logger.py | 1 - sima/utils/startopt.py | 6 +++--- 5 files changed, 11 insertions(+), 13 deletions(-) diff --git a/data/bash/completion.sh b/data/bash/completion.sh index d1d6b64..0a8ff29 100644 --- a/data/bash/completion.sh +++ b/data/bash/completion.sh @@ -33,7 +33,8 @@ _sima() { -S --host \ -P --port \ -h --help --version \ - --var_dir \ + --var-dir --var_dir \ + --generate-config \ -d --daemon" if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then @@ -54,11 +55,11 @@ _sima() { -c|--config) _filedir if [ -z $XDG_DATA_HOME ]; then - local confnames=$(for x in $(ls -1 $HOME/.config/mpd_sima/*.cfg 2>/dev/null) ; do echo "${x##*//}"; done) + local confnames=$(for x in $(ls -1 $HOME/.config/mpd_sima/*.cfg $PWD/*.cfg 2>/dev/null) ; do echo "${x##*//}"; done) else - local confnames=$(for x in $(ls -1 $HOME/.config/mpd_sima/*.cfg $XDG_DATA_HOME/mpd_sima/*.cfg 2>/dev/null) ; do echo "${x##*//}"; done) + local confnames=$(for x in $(ls -1 $HOME/.config/mpd_sima/*.cfg $XDG_DATA_HOME/mpd_sima/*.cfg $PWD/*.cfg 2>/dev/null) ; do echo "${x##*//}"; done) fi - COMPREPLY+=( $(compgen -W "${confnames}") ) + COMPREPLY+=( $(compgen -W "${confnames}" -- ${cur} ) ) return 0 ;; --host|-S) diff --git a/doc/examples/all_settings.cfg b/doc/examples/all_settings.cfg index 65cc61f..e8470be 100644 --- a/doc/examples/all_settings.cfg +++ b/doc/examples/all_settings.cfg @@ -112,10 +112,9 @@ musicbrainzid = True [crop] ## CONSUME # type: integer -# default: unset, not cropping playlist +# default: 10 # description: How many played tracks to keep in the playlist. # Allow to maintain a fixed length playlist. -# Leave commented to keep all tracks #consume = 10 [random] diff --git a/sima/launch.py b/sima/launch.py index 9fb0b2d..4cc60e3 100644 --- a/sima/launch.py +++ b/sima/launch.py @@ -79,14 +79,13 @@ def load_plugins(sima, source): def start(sopt, restart=False): """starts application """ - # set logger - verbosity = sopt.options.get('verbosity', 'warning') # loads configuration config = ConfMan(sopt.options).config + # set logger + logger = logging.getLogger('sima') logfile = config.get('log', 'logfile', fallback=None) verbosity = config.get('log', 'verbosity') set_logger(verbosity, logfile) - logger = logging.getLogger('sima') logger.debug('Command line say: {0}'.format(sopt.options)) # Create Database db_file = config.get('sima', 'db_file') diff --git a/sima/lib/logger.py b/sima/lib/logger.py index 2079406..61d2d25 100644 --- a/sima/lib/logger.py +++ b/sima/lib/logger.py @@ -54,7 +54,6 @@ def set_logger(level='info', logfile=None): logger: level: in debug, info, warning,… logfile: file to log to - """ name = 'sima' if environ.get('TRACE', False): diff --git a/sima/utils/startopt.py b/sima/utils/startopt.py index 2081c19..e393304 100644 --- a/sima/utils/startopt.py +++ b/sima/utils/startopt.py @@ -89,7 +89,7 @@ OPTS = [ configuration. You can put other options with this one to get them in\ the generated configuration.'}, { - 'sw':['--var_dir'], + 'sw':['--var-dir', '--var_dir'], 'dest': 'var_dir', 'action': Wdir, 'help': 'Directory to store var content (ie. database, cache)'}, @@ -106,14 +106,14 @@ OPTS = [ #'help': 'Queue mode in [track, top, album]', 'help': SUPPRESS, }, { - 'sw':['--purge_history'], + 'sw':['--purge-history'], 'action': 'store_true', 'dest': 'do_purge_history', 'help': SUPPRESS}, ] -class StartOpt(object): +class StartOpt: """Command line management. """ -- 2.39.5