From: "André Erdmann" <dywi@mailerd.de>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/R_overlay:master commit in: roverlay/console/
Date: Sat, 23 Aug 2014 19:03:05 +0000 (UTC) [thread overview]
Message-ID: <1408814228.5c640fdb7884f318b306fb10bd6b499b1b7c0f40.dywi@gentoo> (raw)
commit: 5c640fdb7884f318b306fb10bd6b499b1b7c0f40
Author: André Erdmann <dywi <AT> mailerd <DOT> de>
AuthorDate: Sat Aug 23 17:17:08 2014 +0000
Commit: André Erdmann <dywi <AT> mailerd <DOT> de>
CommitDate: Sat Aug 23 17:17:08 2014 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/R_overlay.git;a=commit;h=5c640fdb
console/interpreter: minor improvements
* added --clear option to "history" command
* "set" can now be called without VAR=VALUE
---
roverlay/console/interpreter.py | 31 ++++++++++++++++++++++---------
1 file changed, 22 insertions(+), 9 deletions(-)
diff --git a/roverlay/console/interpreter.py b/roverlay/console/interpreter.py
index 107a14a..00b6ea9 100644
--- a/roverlay/console/interpreter.py
+++ b/roverlay/console/interpreter.py
@@ -334,6 +334,12 @@ class ConsoleInterpreter ( cmd.Cmd ):
parser.add_argument ( "files", metavar='<file>', nargs='*',
help='files to read', type=self.argparse_filepath,
)
+
+ parser = self.get_argparser ( "history", create=True )
+ parser.add_argument ( "-c", "--clear",
+ default=False, action='store_true',
+ help="clear history"
+ )
# --- end of setup_argparser (...) ---
def setup_interpreter ( self ):
@@ -466,7 +472,7 @@ class ConsoleInterpreter ( cmd.Cmd ):
if self.state == ConsoleInterpreterStatus.STATE_CMD_EXEC:
if self.is_onerror():
self.clear_onerror()
- elif self.lastcmd and self.lastcmd != "history":
+ elif self.lastcmd and self.lastcmd.split(None,1)[0] != "history":
self._history.append ( line )
self.state.goto ( "READY" )
@@ -549,8 +555,12 @@ class ConsoleInterpreter ( cmd.Cmd ):
def do_history ( self, line ):
"""Shows the command history."""
- sys.stdout.write ( '\n'.join ( l for l in self._history ) )
- sys.stdout.write ( '\n' )
+ args = self.parse_cmdline ( "history", line )
+ if args.clear:
+ self._history.reset()
+ else:
+ sys.stdout.write ( '\n'.join ( l for l in self._history ) )
+ sys.stdout.write ( '\n' )
# --- end of history (...) ---
def do_pwd ( self, line ):
@@ -657,19 +667,22 @@ class ConsoleInterpreter ( cmd.Cmd ):
# --- end of do_declare (...) ---
def do_set ( self, line ):
- """Sets a variable.
+ """Sets a variable or prints all variables.
- Usage: set VAR=VALUE
+ Usage: set [VAR=VALUE]
Examples:
* set PS1=cmd %
* set dep=fftw 3
"""
- name, sepa, value = line.partition ( '=' )
- if not sepa:
- sys.stderr.write ( "set, bad syntax: {}\n".format ( line ) )
+ if not line:
+ self.do_declare ( line )
else:
- self.set_var ( name.strip(), value )
+ name, sepa, value = line.partition ( '=' )
+ if not sepa:
+ sys.stderr.write ( "set, bad syntax: {}\n".format ( line ) )
+ else:
+ self.set_var ( name.strip(), value )
# --- end of do_set (...) ---
def do_unset ( self, line ):
next reply other threads:[~2014-08-23 19:03 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-23 19:03 André Erdmann [this message]
-- strict thread matches above, loose matches on Subject: below --
2014-04-01 16:38 [gentoo-commits] proj/R_overlay:master commit in: roverlay/console/ André Erdmann
2013-08-23 13:51 André Erdmann
2013-08-06 10:58 André Erdmann
2013-07-24 16:52 André Erdmann
2013-07-24 16:52 André Erdmann
2013-07-24 16:52 André Erdmann
2013-07-23 7:51 André Erdmann
2013-07-23 7:51 André Erdmann
2013-07-23 7:51 André Erdmann
2013-07-19 18:00 [gentoo-commits] proj/R_overlay:gsoc13/next " André Erdmann
2013-07-23 7:51 ` [gentoo-commits] proj/R_overlay:master " André Erdmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1408814228.5c640fdb7884f318b306fb10bd6b499b1b7c0f40.dywi@gentoo \
--to=dywi@mailerd.de \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox