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
4995da7b
Commit
4995da7b
authored
14 years ago
by
Seblu
Browse files
Options
Downloads
Patches
Plain Diff
Introduce new object and tags API with server
parent
c5bbddf1
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
cccli/command/command.py
+35
-25
35 additions, 25 deletions
cccli/command/command.py
cccli/command/list.py
+1
-1
1 addition, 1 deletion
cccli/command/list.py
with
36 additions
and
26 deletions
cccli/command/command.py
+
35
−
25
View file @
4995da7b
...
...
@@ -158,7 +158,7 @@ class TqlCommand(OptionCommand):
if
_options
[
"
callback
"
]
is
not
None
:
_options
[
"
callback
"
](
d
)
if
_options
[
"
status
"
]:
self
.
print_
status
(
d
)
self
.
print_
objects
(
d
,
(
"
output
"
)
)
return
d
except
RpcError
as
e
:
if
_options
[
"
exception
"
]:
...
...
@@ -173,48 +173,58 @@ class TqlCommand(OptionCommand):
except
RpcError
as
e
:
raise
cmdError
(
"
RPCError: %s
"
%
str
(
e
))
# no result, goodbye
if
len
(
objs
)
==
0
:
if
len
(
objs
[
"
objects
"
]
)
==
0
:
raise
cmdError
(
"
No selected object by TQL.
"
)
self
.
printer
.
out
(
"
Objects:
"
)
self
.
print_
taglist
(
objs
)
self
.
printer
.
out
(
"
Objects count: %s
"
%
len
(
objs
))
self
.
print_
objects
(
objs
)
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
"
:
raise
cmdWarning
(
"
User aborted
"
)
# bobby doing many things, he needs to be really sure!
if
len
(
objs
)
>
5
:
if
len
(
objs
[
"
objects
"
]
)
>
5
:
self
.
printer
.
out
(
"
%sYou will act on more than 5 objets!%s
"
%
(
color
[
"
uyellow
"
],
color
[
"
reset
"
]))
if
self
.
printer
.
ask
(
"
%sAre you really sure?%s (Yes Mistress):
"
%
(
color
[
"
lred
"
],
color
[
"
reset
"
]))
!=
"
Yes Mistress
"
:
raise
cmdWarning
(
"
User aborted
"
)
# per validated id execution (this is a kind of atomic implementation)
for
obj
in
objs
:
dobj
=
dict
(
obj
)
for
obj
in
objs
[
"
objects
"
]:
try
:
l
=
list
(
args
)
l
[
_options
[
"
tql_index
"
]]
=
"
id=%s
"
%
d
obj
[
"
id
"
]
l
[
_options
[
"
tql_index
"
]]
=
"
id=%s
"
%
obj
[
"
id
"
]
d
=
self
.
cli
.
rpc
.
call
(
*
tuple
(
l
),
**
kwargs
)
if
_options
[
"
callback
"
]
is
not
None
:
_options
[
"
callback
"
](
d
)
_options
[
"
callback
"
](
obj
[
"
output
"
]
)
if
_options
[
"
status
"
]:
self
.
print_
status
(
d
)
self
.
print_
objects
(
d
,
(
"
output
"
)
)
except
RpcError
as
e
:
self
.
printer
.
error
(
"
RPCError: %s
"
%
str
(
e
))
def
print_taglist
(
self
,
objs
):
'''
Trivial listing of tag
'''
for
o
in
objs
:
self
.
print_tags
(
o
)
def
print_objects
(
self
,
objectlist
,
ignore
=
None
):
'''
Trivial objectlist printing of tag
'''
if
objectlist
is
None
:
return
_order
=
objectlist
.
get
(
"
order
"
,
None
)
for
o
in
objectlist
[
"
objects
"
]:
self
.
print_tags
(
o
,
order
=
_order
,
ignore
=
ignore
)
def
print_tags
(
self
,
taglist
):
def
print_tags
(
self
,
taglist
,
order
=
None
,
ignore
=
None
):
'''
Display a tag with tagdisplay settings
'''
line
=
list
()
for
(
tn
,
tv
)
in
taglist
:
line
.
append
(
"
%s%s:%s%s
"
%
(
self
.
tdtc
(
tn
),
tn
,
self
.
tdc
(
tn
),
self
.
tdr
(
tn
,
tv
)))
self
.
printer
.
out
(
"
%s%s
"
%
(
"
"
.
join
(
line
),
color
[
"
reset
"
]))
def
print_status
(
self
,
outputlist
):
'''
Display status from an object list
'''
if
outputlist
is
not
None
:
for
o
in
outputlist
:
self
.
print_tags
(
o
[
1
][
1
])
_ignore
=
()
if
ignore
is
None
else
ignore
_order
=
()
if
order
is
None
else
order
# copy dict to show
tl
=
taglist
.
copy
()
# remove ignore tags
for
tn
in
_ignore
:
tl
.
pop
(
tn
,
None
)
# list to print
pls
=
[]
# print firstly order tags
for
tn
in
_order
:
tv
=
tl
.
pop
(
tn
,
None
)
if
tv
is
not
None
:
pls
.
append
(
"
%s%s:%s%s
"
%
(
self
.
tdtc
(
tn
),
tn
,
self
.
tdc
(
tn
),
self
.
tdr
(
tn
,
tv
)))
# print next tags without order
for
(
tn
,
tv
)
in
tl
.
items
():
pls
.
append
(
"
%s%s:%s%s
"
%
(
self
.
tdtc
(
tn
),
tn
,
self
.
tdc
(
tn
),
self
.
tdr
(
tn
,
tv
)))
self
.
printer
.
out
(
"
%s%s
"
%
(
"
"
.
join
(
pls
),
color
[
"
reset
"
]))
This diff is collapsed.
Click to expand it.
cccli/command/list.py
+
1
−
1
View file @
4995da7b
...
...
@@ -35,7 +35,7 @@ class Command_list(TqlCommand):
elif
self
.
options
.
table
:
self
.
list_table
(
objs
)
else
:
self
.
print_
taglist
(
objs
)
self
.
print_
objects
(
objs
)
def
list_align
(
self
,
objs
):
'''
Listing line aligned
'''
...
...
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