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
6b4f7c29
Commit
6b4f7c29
authored
14 years ago
by
Seblu
Browse files
Options
Downloads
Patches
Plain Diff
TqlCommand now handle index option
parent
8c63a804
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
cccli/command/command.py
+12
-6
12 additions, 6 deletions
cccli/command/command.py
with
12 additions
and
6 deletions
cccli/command/command.py
+
12
−
6
View file @
6b4f7c29
...
...
@@ -85,6 +85,9 @@ class TqlCommand(OptionCommand):
# set tql status stuff
self
.
add_option
(
"
-q
"
,
"
--quiet
"
,
action
=
"
store_false
"
,
dest
=
"
status
"
,
help
=
"
Dont status of call request
"
)
# index printing
self
.
add_option
(
"
-i
"
,
"
--index
"
,
action
=
"
store_true
"
,
dest
=
"
index
"
,
help
=
"
Print TQL line index
"
)
# tql printer option
self
.
add_option
(
"
--print-tql
"
,
action
=
"
store_true
"
,
dest
=
"
tql_print
"
,
help
=
"
Print TQL before sending to server
"
)
...
...
@@ -126,8 +129,9 @@ class TqlCommand(OptionCommand):
_exception: catch or not RPCError exception
'''
# set default option value
# set
rpccall
default option value
_options
=
{
"
status
"
:
True
,
"
index
"
:
False
,
"
direct
"
:
False
,
"
exception
"
:
False
,
"
tql
"
:
""
,
...
...
@@ -168,7 +172,7 @@ class TqlCommand(OptionCommand):
if
_options
[
"
callback
"
]
is
not
None
:
_options
[
"
callback
"
](
d
)
if
_options
[
"
status
"
]:
self
.
print_objects
(
d
,
[
"
output
"
])
self
.
print_objects
(
d
,
[
"
output
"
]
,
index
=
_options
[
"
index
"
]
)
return
d
except
RpcError
as
e
:
if
_options
[
"
exception
"
]:
...
...
@@ -186,7 +190,7 @@ class TqlCommand(OptionCommand):
if
len
(
objs
[
"
objects
"
])
==
0
:
raise
cmdError
(
"
No selected object by TQL.
"
)
self
.
printer
.
out
(
"
Objects:
"
)
self
.
print_objects
(
objs
)
self
.
print_objects
(
objs
,
index
=
_options
[
"
index
"
]
)
self
.
printer
.
out
(
"
Objects count: %s
"
%
len
(
objs
[
"
objects
"
]))
# be sure boby want do that
if
self
.
printer
.
ask
(
"
%sProceed?%s (yes):
"
%
(
color
[
"
lred
"
],
color
[
"
reset
"
]))
!=
"
yes
"
:
...
...
@@ -206,16 +210,18 @@ class TqlCommand(OptionCommand):
if
_options
[
"
callback
"
]
is
not
None
:
_options
[
"
callback
"
](
obj
)
if
_options
[
"
status
"
]:
self
.
print_objects
(
d
,
[
"
output
"
])
self
.
print_objects
(
d
,
[
"
output
"
]
,
index
=
False
)
except
RpcError
as
e
:
self
.
printer
.
error
(
"
RPCError: %s
"
%
str
(
e
))
def
print_objects
(
self
,
objectlist
,
ignore
=
None
):
def
print_objects
(
self
,
objectlist
,
ignore
=
None
,
index
=
False
):
'''
Trivial objectlist printing of tag
'''
if
objectlist
is
None
:
return
_order
=
objectlist
.
get
(
"
order
"
,
None
)
for
o
in
objectlist
[
"
objects
"
]:
for
(
i
,
o
)
in
enumerate
(
objectlist
[
"
objects
"
]):
if
index
:
self
.
printer
.
out
(
"
[%s]
"
%
i
,
nl
=
""
)
self
.
print_tags
(
o
,
order
=
_order
,
ignore
=
ignore
)
def
print_tags
(
self
,
taglist
,
order
=
None
,
ignore
=
None
):
...
...
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