Permalink
Browse files

csg displays now the starter-script name in the usage (help) output

  • Loading branch information...
spiderbit committed Dec 23, 2009
1 parent 9a69380 commit ba8521ba7420a2044c7904d1d31ec5820e1232b3
Showing with 27 additions and 16 deletions.
  1. +1 −0 docs/changelog.txt
  2. +24 −15 run_song_generator
  3. +2 −1 starter/csg
View
@@ -1,5 +1,6 @@
Canta 0.2.0
+* song-generator displays the name of the starter-script in the usage-screen now
* starter scripts now start from each prefix (this time I hope really ;) )
Canta 0.2-rc2 (2009-08-17)
View
@@ -82,8 +82,8 @@ start_screen = """
Press Enter if you like the preset in []
"""
-
-usage = """
+def print_usage():
+ usage = """
Usage: %s [OPTION]... [FILE]
-h, --help\t\t\tPrints this page
@@ -117,8 +117,8 @@ QUICK MODE (without need of a midi):
supported formats: <%s>
-""" % (sys.argv[0], sys.argv[0], sys.argv[0], sys.argv[0], (', '.join(supported_formats())))
-
+ """ % (name, name, name, name, (', '.join(supported_formats())))
+ print usage
def print_error(error_msg):
@@ -491,20 +491,20 @@ class MainWindow(wx.Frame):
####################################################################################################
-
+name = sys.argv[0]
def main():
try:
- opts, args = getopt.gnu_getopt(sys.argv[1:], "hAm:t:a:e:s:d:", \
+ opts, args = getopt.gnu_getopt(sys.argv[1:], "hAm:t:a:e:s:d:n:", \
["help", "ask", "midi-file", "title=", "artist=", \
- "entries=", "spacing=", "duration="])
+ "entries=", "spacing=", "duration=", "name="])
except getopt.GetoptError, err:
# print help information and exit:
print str(err) # will print something like "option -a not recognized"
- print usage
+ print_usage()
sys.exit(2)
music_file = None
@@ -520,7 +520,8 @@ def main():
if len(args) == 1:
music_file = args[0]
check_file(music_file)
- elif len(args) == 0 and len(opts) == 0:
+ elif len(args) == 0 and (len(opts) == 0 or \
+ len(opts) == 1 and (opts[0][0] == '-n' or opts[0][0] == '--name')):
app = wx.App()
frame = MainWindow()
frame.Show()
@@ -530,10 +531,9 @@ def main():
pass
else:
print sys.argv[0], 'requires a audio file '
- print usage
+ print_usage()
sys.exit(2)
-
for o, a in opts:
if o in ('-m', '--midi-file'):
midi_file = a
@@ -551,8 +551,17 @@ def main():
#verbose = True
elif o in ("-A", "--ask"):
ask = True
+ elif o in ("-n", "--name"):
+ '''
+ name is a intern option for starter scripts
+ to overwrite the usage-starter-name
+ the option must be before -h or --help
+ '''
+
+ global name
+ name = a
elif o in ("-h", "--help"):
- print usage
+ print_usage()
sys.exit(2)
else:
assert False, "unhandled option"
@@ -571,7 +580,7 @@ def get_time(x):
if tones > 0:
return tones
else:
- print usage
+ print_usage()
sys.exit(2)
except:
if x[-1] == 's':
@@ -583,10 +592,10 @@ def get_time(x):
tones = 1
return tones
else:
- print usage
+ print_usage()
sys.exit(2)
except:
- print usage
+ print_usage()
sys.exit(2)
View
@@ -2,4 +2,5 @@
abspath="$(cd "${0%/*}" 2>/dev/null; echo "$PWD"/"${0##*/}")"
path_only=`dirname "$abspath"`
-python $path_only/../share/games/canta/run_song_generator $*
+
+python $path_only/../share/games/canta/run_song_generator -n csg $*

0 comments on commit ba8521b

Please sign in to comment.