Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
P
Printrun
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
machinery
Printrun
Commits
d2c1b08e
Commit
d2c1b08e
authored
Jun 01, 2011
by
Keegi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
alias tab-completion and better integration to built-in help
parent
efaf64de
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
3 deletions
+15
-3
pronsole.py
pronsole.py
+15
-3
No files found.
pronsole.py
View file @
d2c1b08e
...
...
@@ -91,7 +91,7 @@ class pronsole(cmd.Cmd):
if
alias_def
.
lower
()
==
"/d"
:
# delete alias
if
alias_name
in
self
.
aliases
.
keys
():
delattr
(
self
,
"do_"
+
alias_name
)
delattr
(
self
.
__class__
,
"do_"
+
alias_name
)
del
self
.
aliases
[
alias_name
]
print
"Alias '"
+
alias_name
+
"' removed"
return
...
...
@@ -99,9 +99,10 @@ class pronsole(cmd.Cmd):
print
"Alias '"
+
alias_name
+
"' is not defined"
return
# (re)define an alias
func
=
lambda
args
,
self
=
self
,
alias_def
=
alias_def
:
self
.
onecmd
(
" "
.
join
((
alias_def
,
args
)))
func
=
lambda
self
,
args
,
alias_def
=
alias_def
:
self
.
onecmd
(
" "
.
join
((
alias_def
,
args
)))
self
.
aliases
[
alias_name
]
=
alias_def
setattr
(
self
,
"do_"
+
alias_name
,
func
)
setattr
(
self
.
__class__
,
"do_"
+
alias_name
,
func
)
setattr
(
self
.
__class__
,
"help_"
+
alias_name
,
lambda
self
=
self
,
alias_name
=
alias_name
:
self
.
subhelp_alias
(
alias_name
))
def
help_alias
(
self
):
print
"Create/modify/view aliases: alias <name> [<command>]"
...
...
@@ -109,6 +110,17 @@ class pronsole(cmd.Cmd):
print
"without arguments, displays list of all defined aliases"
print
"To remove an alias: alias <name> /d"
def
complete_alias
(
self
,
text
,
line
,
begidx
,
endidx
):
if
(
len
(
line
.
split
())
==
2
and
line
[
-
1
]
!=
" "
)
or
(
len
(
line
.
split
())
==
1
and
line
[
-
1
]
==
" "
):
return
[
i
for
i
in
self
.
aliases
.
keys
()
if
i
.
startswith
(
text
)]
elif
(
len
(
line
.
split
())
==
3
or
(
len
(
line
.
split
())
==
2
and
line
[
-
1
]
==
" "
)):
return
self
.
completenames
(
text
)
else
:
return
[]
def
subhelp_alias
(
self
,
alias_name
):
print
"'"
+
alias_name
+
"' is alias for '"
+
self
.
aliases
[
alias_name
]
+
"'"
def
postloop
(
self
):
self
.
p
.
disconnect
()
cmd
.
Cmd
.
postloop
(
self
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment