Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cc-cli
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Mirror
cc-cli
Commits
280652a2
Commit
280652a2
authored
14 years ago
by
Seblu
Browse files
Options
Downloads
Patches
Plain Diff
correctly handle ? and ! completion and execution
parent
a5822e51
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
cccli/cli.py
+17
-9
17 additions, 9 deletions
cccli/cli.py
cccli/printer.py
+1
-0
1 addition, 0 deletions
cccli/printer.py
with
18 additions
and
9 deletions
cccli/cli.py
+
17
−
9
View file @
280652a2
...
@@ -120,19 +120,24 @@ class Cli(object):
...
@@ -120,19 +120,24 @@ class Cli(object):
def
_exec_command
(
self
,
argv
):
def
_exec_command
(
self
,
argv
):
'''
Execute command
'''
'''
Execute command
'''
self
.
printer
.
debug
(
"
argv: %s
"
%
argv
)
try
:
try
:
if
(
argv
[
0
][
0
]
==
"
!
"
):
# handle ! in command name
if
argv
[
0
][
0
]
==
"
!
"
:
argv
[
0
]
=
argv
[
0
][
1
:]
argv
[
0
]
=
argv
[
0
][
1
:]
if
not
len
(
argv
[
0
]):
if
not
len
(
argv
[
0
]):
return
return
p
=
subprocess
.
Popen
(
argv
,
close_fds
=
True
,
shell
=
True
)
p
=
subprocess
.
Popen
(
argv
,
close_fds
=
True
,
shell
=
True
)
p
.
wait
()
p
.
wait
()
ret
=
p
.
returncode
ret
=
p
.
returncode
elif
(
argv
[
0
]
==
"
?
"
):
return
Command
([
"
help
"
],
self
).
call
()
# handle ? in command name
else
:
if
argv
[
0
][
0
]
==
"
?
"
:
Command
(
argv
,
self
).
call
()
if
len
(
argv
[
0
])
>
1
:
argv
.
insert
(
1
,
argv
[
0
][
1
:])
argv
[
0
]
=
"
help
"
# execute command
self
.
printer
.
debug
(
"
argv: %s
"
%
argv
)
Command
(
argv
,
self
).
call
()
except
cmdBadArgument
as
e
:
except
cmdBadArgument
as
e
:
if
str
(
e
):
if
str
(
e
):
self
.
printer
.
error
(
"
Bad argument: %s.
"
%
str
(
e
))
self
.
printer
.
error
(
"
Bad argument: %s.
"
%
str
(
e
))
...
@@ -150,8 +155,7 @@ class Cli(object):
...
@@ -150,8 +155,7 @@ class Cli(object):
except
EOFError
:
except
EOFError
:
self
.
printer
.
out
(
""
)
self
.
printer
.
out
(
""
)
except
Exception
as
e
:
except
Exception
as
e
:
if
cccli
.
debug
:
if
cccli
.
debug
:
raise
raise
self
.
printer
.
error
(
"
%s: %s
"
%
(
type
(
e
),
str
(
e
)))
self
.
printer
.
error
(
"
%s: %s
"
%
(
type
(
e
),
str
(
e
)))
self
.
printer
.
warn
(
"
This is a not expected error, please report it!
"
)
self
.
printer
.
warn
(
"
This is a not expected error, please report it!
"
)
...
@@ -160,7 +164,11 @@ class Cli(object):
...
@@ -160,7 +164,11 @@ class Cli(object):
comp
=
self
.
printer
.
completion
comp
=
self
.
printer
.
completion
stripped
=
comp
.
get_buf
()[:
comp
.
get_begin
()
+
1
].
lstrip
()
stripped
=
comp
.
get_buf
()[:
comp
.
get_begin
()
+
1
].
lstrip
()
if
texte
==
""
and
stripped
!=
""
:
if
texte
==
""
and
stripped
!=
""
:
return
None
return
()
if
len
(
texte
)
>
0
and
texte
[
0
]
==
"
!
"
:
return
()
if
len
(
texte
)
>
0
and
texte
[
0
]
==
"
?
"
:
texte
=
texte
[
1
:]
return
[
c
for
c
in
Command
.
list
()
+
self
.
alias
.
keys
()
if
c
.
startswith
(
texte
)
]
return
[
c
for
c
in
Command
.
list
()
+
self
.
alias
.
keys
()
if
c
.
startswith
(
texte
)
]
class
CliHandler
(
RpcHandler
):
class
CliHandler
(
RpcHandler
):
...
...
This diff is collapsed.
Click to expand it.
cccli/printer.py
+
1
−
0
View file @
280652a2
...
@@ -259,3 +259,4 @@ class Completion(object):
...
@@ -259,3 +259,4 @@ class Completion(object):
self
.
compfunc
=
func
self
.
compfunc
=
func
self
.
readline
.
set_completer
(
self
.
_completer
)
self
.
readline
.
set_completer
(
self
.
_completer
)
self
.
readline
.
parse_and_bind
(
"
tab: complete
"
)
self
.
readline
.
parse_and_bind
(
"
tab: complete
"
)
self
.
readline
.
set_completer_delims
(
"
\t
"
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment