Update examples
This commit is contained in:
29
readline/mtg.py
Normal file → Executable file
29
readline/mtg.py
Normal file → Executable file
@ -1,15 +1,25 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
This module defines a command-line interface (CLI) application which allows
|
||||
users to interact with a predefined list of completion options, specifically,
|
||||
card names from the "Alara Reborn" set.
|
||||
|
||||
It leverages the `cmd` module to build the CLI and has tab-completion
|
||||
functionality for adding items from the predefined list of card names.
|
||||
"""
|
||||
import cmd
|
||||
|
||||
completions = [
|
||||
'Mage Slayer (Alara Reborn)',
|
||||
'Magefire Wings (Alara Reborn)',
|
||||
'Sages of the Anima (Alara Reborn)',
|
||||
'Sanctum Plowbeast (Alara Reborn)',
|
||||
'Sangrite Backlash (Alara Reborn)',
|
||||
'Sanity Gnawers (Alara Reborn)',
|
||||
'Sen Triplets (Alara Reborn)'
|
||||
"Mage Slayer (Alara Reborn)",
|
||||
"Magefire Wings (Alara Reborn)",
|
||||
"Sages of the Anima (Alara Reborn)",
|
||||
"Sanctum Plowbeast (Alara Reborn)",
|
||||
"Sangrite Backlash (Alara Reborn)",
|
||||
"Sanity Gnawers (Alara Reborn)",
|
||||
"Sen Triplets (Alara Reborn)",
|
||||
]
|
||||
|
||||
|
||||
class mycmd(cmd.Cmd):
|
||||
def __init__(self):
|
||||
cmd.Cmd.__init__(self)
|
||||
@ -21,9 +31,10 @@ class mycmd(cmd.Cmd):
|
||||
pass
|
||||
|
||||
def complete_add(self, text, line, begidx, endidx):
|
||||
mline = line.partition(' ')[2]
|
||||
mline = line.partition(" ")[2]
|
||||
offs = len(mline) - len(text)
|
||||
return [s[offs:] for s in completions if s.startswith(mline)]
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
if __name__ == "__main__":
|
||||
mycmd().cmdloop()
|
||||
|
Reference in New Issue
Block a user