Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #89478
| Date | 2015-04-27 22:28 -0700 |
|---|---|
| From | Ethan Furman <ethan@stoneleaf.us> |
| Subject | Re: Clize 3.0b1: An argument parser that draws a CLI from your function sigature |
| References | <CANUJvPWSO8bW3mNh1_wCH6qcoGtUE=9zJ71acdga8d0vViZZ8Q@mail.gmail.com> <CAPTjJmqbnupbzoKA20gMAT9pnkH1rr5XAsBLeqrjtFwC=6-2Ug@mail.gmail.com> <CANUJvPVCnJ146W5Jm-=L4ButFudZzPear3DpAzVbmbQGU7b1cw@mail.gmail.com> <CAPTjJmqSni3m1nDvQgDmVmm5wgWY=GYM3DRqHeVGHA8tHfQ-uw@mail.gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.53.1430198945.3680.python-list@python.org> (permalink) |
On 04/28, Chris Angelico wrote:
> That's a lot of separate pieces. Here's the docstringargs equivalent:
>
> https://github.com/Rosuav/snippets/blob/dsa/snippets.py
Just for grins, here's that using Scription:
-- 8< --------------------------------------------------------------------
"""Store and retrieve snippets of text"""
from scription import *
import logging
# Set the log output file, and the log level
logging.basicConfig(filename="snippets.log", level=logging.DEBUG)
data = {}
@Script()
def main():
print('Result: {!r}'.format(script_command()))
@Command(
name=('the name of the snippet', ),
snippet=('the snippet text', ),
)
def put(name, snippet):
"Store a snippet with an associated name."
logging.info("Storing({!r}, {!r})".format(name, snippet))
data[name] = snippet
return name, snippet
@Command(
name=('the name of the snippet', ),
)
def get(name):
"Retrieve the snippet with a given name."
logging.error("Retrieving({!r})".format(name))
return data.get(name)
Main()
-- 8< --------------------------------------------------------------------
and a sample run with nothing selected:
-- 8< --------------------------------------------------------------------
$ python snippet
Store and retrieve snippets of text
snippet get NAME
Retrieve the snippet with a given name.
NAME the name of the snippet
snippet put NAME SNIPPET
Store a snippet with an associated name.
NAME the name of the snippet
SNIPPET the snippet text
-- 8< --------------------------------------------------------------------
--
~Ethan~
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Clize 3.0b1: An argument parser that draws a CLI from your function sigature Ethan Furman <ethan@stoneleaf.us> - 2015-04-27 22:28 -0700
csiph-web