MCPcopy Create free account
hub / github.com/ActiveState/code / cmd_line

Function cmd_line

recipes/Python/578207_Console_CD_Player/recipe-578207.py:47–69  ·  view source on GitHub ↗
(disc, index)

Source from the content-addressed store, hash-verified

45 disc.quit()
46
47def cmd_line(disc, index):
48 while True:
49 prompt = get_prompt()
50 if prompt == 'nop':
51 pass
52 elif prompt == 'help':
53 print 'help: get this message'
54 print 'nop: does nothing'
55 print 'total: shows total tracks'
56 print 'play: plays the selected track'
57 print 'quit: leaves the commmand line'
58 elif prompt == 'total':
59 print 'There are %s tracks.' % len(index)
60 elif prompt == 'play':
61 track = get_track(len(index))
62 if track != -1:
63 disc.play(index[track])
64 else:
65 print 'Okay ...'
66 elif prompt == 'quit':
67 return
68 else:
69 print '"%s" cannot be understood.' % prompt
70
71def get_prompt():
72 try:

Callers 1

cmdFunction · 0.85

Calls 3

get_promptFunction · 0.85
get_trackFunction · 0.85
playMethod · 0.45

Tested by

no test coverage detected