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
bb886079
Commit
bb886079
authored
13 years ago
by
Seblu
Browse files
Options
Downloads
Patches
Plain Diff
Print count of object when displaying it
parent
cca4ba4e
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/command.py
+12
-7
12 additions, 7 deletions
cccli/command.py
cccli/commands/list.py
+9
-0
9 additions, 0 deletions
cccli/commands/list.py
with
21 additions
and
7 deletions
cccli/command.py
+
12
−
7
View file @
bb886079
...
@@ -197,6 +197,15 @@ class RemoteCommand(OptionCommand):
...
@@ -197,6 +197,15 @@ class RemoteCommand(OptionCommand):
def
__init__
(
self
,
cli
,
argv0
):
def
__init__
(
self
,
cli
,
argv0
):
OptionCommand
.
__init__
(
self
,
cli
,
argv0
)
OptionCommand
.
__init__
(
self
,
cli
,
argv0
)
# ignore tag option
self
.
add_option
(
"
-I
"
,
"
--ignore-tag
"
,
action
=
"
append
"
,
dest
=
"
ignore
"
,
default
=
[],
help
=
"
Don
'
t display a tag in objects
"
)
# no print count at end option
self
.
add_option
(
"
--no-count
"
,
action
=
"
store_true
"
,
dest
=
"
nocount
"
,
help
=
"
Don
'
t print count at end of objects
"
)
# index printing
self
.
add_option
(
"
-i
"
,
"
--index
"
,
action
=
"
store_true
"
,
dest
=
"
index
"
,
help
=
"
Print object lines indexed
"
)
self
.
rpc
=
cli
.
rpc
self
.
rpc
=
cli
.
rpc
def
remote_functions
(
self
):
def
remote_functions
(
self
):
...
@@ -209,10 +218,12 @@ class RemoteCommand(OptionCommand):
...
@@ -209,10 +218,12 @@ class RemoteCommand(OptionCommand):
return
return
# get default index from local options
# get default index from local options
_order
=
objectlist
.
get
(
"
order
"
,
None
)
_order
=
objectlist
.
get
(
"
order
"
,
None
)
for
(
i
,
o
)
in
enumerate
(
objectlist
[
"
objects
"
]):
for
(
i
,
o
)
in
enumerate
(
objectlist
[
"
objects
"
]):
if
self
.
options
.
index
:
if
self
.
options
.
index
:
self
.
printer
.
out
(
"
[%s]
"
%
i
,
nl
=
""
)
self
.
printer
.
out
(
"
[%s]
"
%
i
,
nl
=
""
)
self
.
print_tags
(
o
,
order
=
_order
)
self
.
print_tags
(
o
,
order
=
_order
)
if
not
self
.
options
.
nocount
:
self
.
printer
.
out
(
"
Objects count: %s
"
%
len
(
objectlist
[
"
objects
"
]))
def
print_tags
(
self
,
taglist
,
order
=
None
):
def
print_tags
(
self
,
taglist
,
order
=
None
):
'''
Display a tag with tagdisplay settings
'''
'''
Display a tag with tagdisplay settings
'''
...
@@ -252,14 +263,9 @@ class TqlCommand(RemoteCommand):
...
@@ -252,14 +263,9 @@ class TqlCommand(RemoteCommand):
# set tql status stuff
# set tql status stuff
self
.
add_option
(
"
-q
"
,
"
--quiet
"
,
action
=
"
store_false
"
,
dest
=
"
status
"
,
self
.
add_option
(
"
-q
"
,
"
--quiet
"
,
action
=
"
store_false
"
,
dest
=
"
status
"
,
help
=
"
Dont status of call request
"
)
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
# tql printer option
self
.
add_option
(
"
--print-tql
"
,
action
=
"
store_true
"
,
dest
=
"
tql_print
"
,
self
.
add_option
(
"
--print-tql
"
,
action
=
"
store_true
"
,
dest
=
"
tql_print
"
,
help
=
"
Print TQL before sending to server
"
)
help
=
"
Print TQL before sending to server
"
)
self
.
add_option
(
"
-I
"
,
"
--ignore-tag
"
,
action
=
"
append
"
,
dest
=
"
ignore
"
,
default
=
[],
help
=
"
Don
'
t display a tag
"
)
# set tagdisplay stuff
# set tagdisplay stuff
self
.
tdr
=
self
.
cli
.
tagdisplay
.
resolve
self
.
tdr
=
self
.
cli
.
tagdisplay
.
resolve
self
.
tdc
=
self
.
cli
.
tagdisplay
.
color
self
.
tdc
=
self
.
cli
.
tagdisplay
.
color
...
@@ -372,7 +378,6 @@ class TqlCommand(RemoteCommand):
...
@@ -372,7 +378,6 @@ class TqlCommand(RemoteCommand):
raise
cmdError
(
"
No selected object by TQL.
"
)
raise
cmdError
(
"
No selected object by TQL.
"
)
self
.
printer
.
out
(
"
Objects:
"
)
self
.
printer
.
out
(
"
Objects:
"
)
self
.
print_objects
(
objs
)
self
.
print_objects
(
objs
)
self
.
printer
.
out
(
"
Objects count: %s
"
%
len
(
objs
[
"
objects
"
]))
# be sure boby want do that
# be sure boby want do that
if
self
.
printer
.
ask
(
"
%sProceed?%s (yes):
"
%
(
color
[
"
lred
"
],
color
[
"
reset
"
]))
!=
"
yes
"
:
if
self
.
printer
.
ask
(
"
%sProceed?%s (yes):
"
%
(
color
[
"
lred
"
],
color
[
"
reset
"
]))
!=
"
yes
"
:
raise
cmdWarning
(
"
User aborted
"
)
raise
cmdWarning
(
"
User aborted
"
)
...
...
This diff is collapsed.
Click to expand it.
cccli/commands/list.py
+
9
−
0
View file @
bb886079
...
@@ -113,6 +113,9 @@ class Command_list(TqlCommand):
...
@@ -113,6 +113,9 @@ class Command_list(TqlCommand):
tmp_pos
+=
1
tmp_pos
+=
1
new_line
=
not
found_pos
and
not
first_line
new_line
=
not
found_pos
and
not
first_line
self
.
printer
.
out
(
"
%s%s
"
%
(
line
,
color
[
"
reset
"
]))
self
.
printer
.
out
(
"
%s%s
"
%
(
line
,
color
[
"
reset
"
]))
if
not
self
.
options
.
nocount
:
self
.
printer
.
out
(
"
Objects count: %s
"
%
len
(
objs
[
"
objects
"
]))
def
list_table
(
self
,
objs
):
def
list_table
(
self
,
objs
):
'''
Listing table style
'''
'''
Listing table style
'''
...
@@ -175,6 +178,8 @@ class Command_list(TqlCommand):
...
@@ -175,6 +178,8 @@ class Command_list(TqlCommand):
self
.
printer
.
out
(
buf
,
nl
=
""
)
self
.
printer
.
out
(
buf
,
nl
=
""
)
self
.
printer
.
out
(
color
[
"
reset
"
])
self
.
printer
.
out
(
color
[
"
reset
"
])
order
=
order
[
tag_index
:]
order
=
order
[
tag_index
:]
if
not
self
.
options
.
nocount
:
self
.
printer
.
out
(
"
Objects count: %s
"
%
len
(
objs
[
"
objects
"
]))
def
list_vertical
(
self
,
objs
):
def
list_vertical
(
self
,
objs
):
'''
Vertical display
'''
'''
Vertical display
'''
...
@@ -217,6 +222,8 @@ class Command_list(TqlCommand):
...
@@ -217,6 +222,8 @@ class Command_list(TqlCommand):
else
:
else
:
line
+=
(
buf
[:
-
(
margin
+
1
)]
+
os
.
linesep
)
line
+=
(
buf
[:
-
(
margin
+
1
)]
+
os
.
linesep
)
self
.
printer
.
out
(
"
%s%s
"
%
(
line
[:
-
1
],
color
[
"
reset
"
]))
self
.
printer
.
out
(
"
%s%s
"
%
(
line
[:
-
1
],
color
[
"
reset
"
]))
if
not
self
.
options
.
nocount
:
self
.
printer
.
out
(
"
Objects count: %s
"
%
len
(
objs
[
"
objects
"
]))
def
list_mikrotik
(
self
,
objs
):
def
list_mikrotik
(
self
,
objs
):
'''
Mikrotik style display
'''
'''
Mikrotik style display
'''
...
@@ -281,6 +288,8 @@ class Command_list(TqlCommand):
...
@@ -281,6 +288,8 @@ class Command_list(TqlCommand):
buf
,
line_pos
=
self
.
_format_indent_text
(
self
.
tdr
(
tag
,
o
.
get
(
tag
))
+
"
"
,
line_pos
,
margin
,
term_width
)
buf
,
line_pos
=
self
.
_format_indent_text
(
self
.
tdr
(
tag
,
o
.
get
(
tag
))
+
"
"
,
line_pos
,
margin
,
term_width
)
line
+=
self
.
tdc
(
tag
)
+
buf
line
+=
self
.
tdc
(
tag
)
+
buf
self
.
printer
.
out
(
"
%s%s%s
"
%
(
line
,
color
[
"
reset
"
],
os
.
linesep
))
self
.
printer
.
out
(
"
%s%s%s
"
%
(
line
,
color
[
"
reset
"
],
os
.
linesep
))
if
not
self
.
options
.
nocount
:
self
.
printer
.
out
(
"
Objects count: %s
"
%
len
(
objs
[
"
objects
"
]))
def
_format_indent_text
(
self
,
text
,
current_pos
,
min_pos
,
max_pos
):
def
_format_indent_text
(
self
,
text
,
current_pos
,
min_pos
,
max_pos
):
'''
Reformat text to start in current_pos and fit in column between min_pos and max_pos
'''
Reformat text to start in current_pos and fit in column between min_pos and max_pos
...
...
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