-
Notifications
You must be signed in to change notification settings - Fork 29
/
juju-pprint
executable file
·50 lines (40 loc) · 1.51 KB
/
juju-pprint
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/python
#
# Copyright 2014 Marco Ceppi <[email protected]>
#
# juju-pprint is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# juju-pprint is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# For a full copy of the GNU General Public License, see
# <http://www.gnu.org/licenses/>.
import sys
from utils import get_units, print_unit, get_max_lens
def main():
# I heard they invented this cool thing called argparse
if '--description' in sys.argv:
print "Collapsed, pretty version of juju status"
sys.exit()
if '--help' in sys.argv:
print "Usage: juju pprint [options]"
print "Collapsed, pretty version of juju stats"
print ""
print "Options:"
print " -q Use quiet (super-condensed) mode"
print " -a Use aligned mode"
sys.exit()
quiet = '-q' in sys.argv
align = not quiet and '-a' in sys.argv
units = get_units()
name_width, addr_width, stat_width = get_max_lens(units, align)
for unit in units:
indent = 2 if unit.subordinate else 0
print_unit(unit, indent, quiet, name_width, addr_width, stat_width)
if __name__ == "__main__":
main()