Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cc-cli
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
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
41093b1c
Commit
41093b1c
authored
14 years ago
by
Seblu
Browse files
Options
Downloads
Patches
Plain Diff
Aliases remplace Aliase
parent
58cd582b
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
cccli/cli.py
+8
-8
8 additions, 8 deletions
cccli/cli.py
cccli/command/alias.py
+14
-8
14 additions, 8 deletions
cccli/command/alias.py
cccli/commands.py
+4
-7
4 additions, 7 deletions
cccli/commands.py
with
26 additions
and
23 deletions
cccli/cli.py
+
8
−
8
View file @
41093b1c
...
...
@@ -9,7 +9,7 @@ CloudControl CLI main module
import
cccli
from
cccli.exception
import
*
from
cccli.printer
import
Printer
,
color
from
cccli.commands
import
Commands
,
Alias
from
cccli.commands
import
Commands
,
Alias
es
from
cccli.handler
import
CliHandler
from
cccli.tagdisplay
import
TagDisplay
from
sjrpc.core.exceptions
import
*
...
...
@@ -27,7 +27,7 @@ class Cli(object):
def
__init__
(
self
,
settings
):
self
.
settings
=
settings
self
.
rpc
=
None
self
.
alias
=
Alias
()
self
.
alias
es
=
Alias
es
()
self
.
tagdisplay
=
TagDisplay
()
self
.
prompt
=
""
...
...
@@ -59,8 +59,8 @@ class Cli(object):
self
.
commands
=
Commands
(
self
)
self
.
printer
.
debug
(
"
Loaded commands: %d
"
%
len
(
self
.
commands
))
# load alias
self
.
alias
.
load
(
self
.
settings
.
get
(
"
alias
"
,
""
))
self
.
printer
.
debug
(
"
Loaded aliases: %d
"
%
len
(
self
.
alias
))
self
.
alias
es
.
load
(
self
.
settings
.
get
(
"
alias
"
,
None
))
self
.
printer
.
debug
(
"
Loaded aliases: %d
"
%
len
(
self
.
alias
es
))
# load tagdisplay
self
.
tagdisplay
.
load
(
self
.
settings
.
get
(
"
tagdisplay
"
,
""
))
# connecting
...
...
@@ -111,9 +111,9 @@ class Cli(object):
if
len
(
argv
)
==
0
:
continue
# alias subsitution
if
argv
[
0
]
in
self
.
alias
:
if
argv
[
0
]
in
self
.
alias
es
:
oldargv
=
argv
[
1
:]
argv
=
shlex
.
split
(
self
.
alias
[
argv
[
0
]])
argv
=
shlex
.
split
(
self
.
alias
es
[
argv
[
0
]])
argv
.
extend
(
oldargv
)
self
.
_exec_command
(
argv
)
except
KeyboardInterrupt
:
...
...
@@ -177,5 +177,5 @@ class Cli(object):
if
len
(
texte
)
>
0
and
texte
[
0
]
==
"
!
"
:
return
()
if
len
(
texte
)
>
0
and
texte
[
0
]
==
"
?
"
:
return
[
"
?%s
"
%
c
for
c
in
list
(
self
.
commands
)
+
self
.
alias
.
keys
()
if
c
.
startswith
(
texte
[
1
:])
]
return
[
c
for
c
in
list
(
self
.
commands
)
+
self
.
alias
.
keys
()
if
c
.
startswith
(
texte
)
]
return
[
"
?%s
"
%
c
for
c
in
list
(
self
.
commands
)
+
self
.
alias
es
.
keys
()
if
c
.
startswith
(
texte
[
1
:])
]
return
[
c
for
c
in
list
(
self
.
commands
)
+
self
.
alias
es
.
keys
()
if
c
.
startswith
(
texte
)
]
This diff is collapsed.
Click to expand it.
cccli/command/alias.py
+
14
−
8
View file @
41093b1c
...
...
@@ -21,7 +21,7 @@ class Command_alias(OptionCommand):
self
.
parse_args
(
argv
)
_value
=
None
if
len
(
self
.
args
)
==
0
:
_alias
=
self
.
cli
.
alias
.
keys
()
_alias
=
self
.
cli
.
alias
es
.
keys
()
elif
len
(
self
.
args
)
==
1
:
_alias
=
[
self
.
args
[
0
]
]
elif
len
(
self
.
args
)
==
2
:
...
...
@@ -32,14 +32,17 @@ class Command_alias(OptionCommand):
# printing
if
_value
is
None
:
for
a
in
_alias
:
if
a
in
self
.
cli
.
alias
:
self
.
printer
.
out
(
"
%s
\"
%s
\"
"
%
(
a
,
re
.
sub
(
"
\"
"
,
"
\\\"
"
,
self
.
cli
.
alias
[
a
])))
if
a
in
self
.
cli
.
alias
es
:
self
.
printer
.
out
(
"
%s
\"
%s
\"
"
%
(
a
,
re
.
sub
(
"
\"
"
,
"
\\\"
"
,
self
.
cli
.
alias
es
[
a
])))
else
:
self
.
printer
.
warn
(
"
No alias %s
"
%
a
)
# editing
else
:
self
.
cli
.
alias
[
_alias
]
=
_value
self
.
cli
.
alias
.
save
(
self
.
cli
.
settings
.
get
(
"
alias
"
,
""
))
self
.
cli
.
aliases
[
_alias
]
=
_value
try
:
self
.
cli
.
aliases
.
save
(
self
.
cli
.
settings
.
get
(
"
alias
"
,
None
))
except
Exception
as
e
:
raise
cmdError
(
e
)
class
Command_unalias
(
OptionCommand
):
...
...
@@ -55,8 +58,11 @@ class Command_unalias(OptionCommand):
if
len
(
self
.
args
)
!=
1
:
raise
cmdBadArgument
()
# check alias existance
if
self
.
args
[
0
]
not
in
self
.
cli
.
alias
:
if
self
.
args
[
0
]
not
in
self
.
cli
.
alias
es
:
raise
cmdBadArgument
(
"
%s: No such alias
"
%
self
.
args
[
0
])
# deleting aliases
del
self
.
cli
.
alias
[
self
.
args
[
0
]]
self
.
cli
.
alias
.
save
(
self
.
cli
.
settings
.
get
(
"
alias
"
,
""
))
del
self
.
cli
.
aliases
[
self
.
args
[
0
]]
try
:
self
.
cli
.
aliases
.
save
(
self
.
cli
.
settings
.
get
(
"
alias
"
,
None
))
except
Exception
as
e
:
raise
cmdError
(
e
)
This diff is collapsed.
Click to expand it.
cccli/commands.py
+
4
−
7
View file @
41093b1c
...
...
@@ -59,11 +59,11 @@ class Commands(object):
h
=
self
.
cmds
[
argv0
](
self
.
cli
,
argv0
).
help
()
return
h
if
h
is
not
None
else
""
class
Alias
(
dict
):
'''
Alias
wrapp
er
'''
class
Alias
es
(
dict
):
'''
Alias
es manag
er
'''
def
load
(
self
,
filename
):
'''
load alias from file
'''
if
os
.
access
(
filename
,
os
.
R_OK
)
:
if
filename
is
not
None
:
fparser
=
ConfigParser
.
RawConfigParser
()
fparser
.
read
(
filename
)
if
fparser
.
has_section
(
"
alias
"
):
...
...
@@ -72,7 +72,7 @@ class Alias(dict):
def
save
(
self
,
filename
):
'''
save alias on file
'''
if
os
.
access
(
filename
,
os
.
R_OK
or
os
.
W_OK
)
:
if
filename
is
not
None
:
fparser
=
ConfigParser
.
RawConfigParser
()
fparser
.
read
(
filename
)
fparser
.
remove_section
(
"
alias
"
)
...
...
@@ -80,6 +80,3 @@ class Alias(dict):
for
n
,
v
in
self
.
items
():
fparser
.
set
(
"
alias
"
,
n
,
v
)
fparser
.
write
(
open
(
filename
,
"
w
"
))
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