]> kaliko git repositories - mpd-sima.git/blobdiff - sima/utils/startopt.py
Now use "var-dir" as option name
[mpd-sima.git] / sima / utils / startopt.py
index ef2032c13b0f013c1fecc3a5b0fd4ee21c3e7bc3..86463097a696c7a38ae83ac4397a044d63563b84 100644 (file)
@@ -1,6 +1,6 @@
 # -*- coding: utf-8 -*-
 
-# Copyright (c) 2009, 2010, 2011, 2012, 2013, 2014 Jack Kaliko <kaliko@azylum.org>
+# Copyright (c) 2009, 2010, 2011, 2012, 2013, 2014, 2015 Jack Kaliko <kaliko@azylum.org>
 #
 #  This file is part of sima
 #
@@ -24,12 +24,9 @@ from argparse import (ArgumentParser, SUPPRESS)
 
 from .utils import Wfile, Rfile, Wdir
 
-USAGE = """USAGE:  %prog [--help] [options]"""
 DESCRIPTION = """
-sima automagicaly queue new tracks in MPD playlist.
-All command line options will override their equivalent in configuration
-file.
-"""
+MPD_sima automagicaly queue new tracks in MPD playlist.
+Command line options override their equivalent in configuration file."""
 
 
 def clean_dict(to_clean):
@@ -85,7 +82,14 @@ OPTS = [
         'action': Rfile,
         'help': 'Configuration file to load'},
     {
-        'sw':['--var_dir'],
+        'sw':['--generate-config'],
+        'dest': 'generate_config',
+        'action': 'store_true',
+        'help': 'Generate a sample configuration file to stdout according to the current\
+         configuration. You can put other options with this one to get them in\
+         the generated configuration.'},
+    {
+        'sw':['--var-dir', '--var_dir'],
         'dest': 'var_dir',
         'action': Wdir,
         'help': 'Directory to store var content (ie. database, cache)'},
@@ -94,7 +98,7 @@ OPTS = [
         'action': 'store_true',
         'dest': 'create_db',
         'help': '''Create database and exit, use destination
-                   specified in --var_dir or standard location.'''},
+                   specified in --var-dir or standard location.'''},
     {
         'sw':['--queue-mode', '-q'],
         'dest': 'queue_mode',
@@ -102,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.
     """
 
@@ -124,12 +128,11 @@ class StartOpt(object):
         Declare options in ArgumentParser object.
         """
         self.parser = ArgumentParser(description=DESCRIPTION,
-                                   usage='%(prog)s [options]',
-                                   prog=self.info.get('prog'),
-                                   epilog='Happy Listening',
-                )
+                                     prog=self.info.get('prog'),
+                                     epilog='Happy Listening',
+                                    )
         self.parser.add_argument('--version', action='version',
-                version='%(prog)s {version}'.format(**self.info))
+                        version='%(prog)s {version}'.format(**self.info))
         # Add all options declare in OPTS
         for opt in OPTS:
             opt_names = opt.pop('sw')