1919
2020'''
2121
22- from scompose .logger import bot
2322import scompose
2423import argparse
2524import sys
@@ -31,7 +30,7 @@ def get_parser():
3130 parser = argparse .ArgumentParser (description = "Singularity Compose" )
3231
3332 # Verbosity
34- parser .add_argument ('--verbose ' , dest = "verbose " ,
33+ parser .add_argument ('--debug ' , dest = "debug " ,
3534 help = "use verbose logging to debug." ,
3635 default = False , action = 'store_true' )
3736
@@ -67,7 +66,7 @@ def get_parser():
6766 dest = "command" )
6867
6968 # print version and exit
70- version = subparsers .add_parser ("version" ,
69+ version = subparsers .add_parser ("version" , # pylint: disable=unused-variable
7170 help = "show software version" )
7271
7372
@@ -79,7 +78,7 @@ def get_parser():
7978
8079 # Config
8180
82- config = subparsers .add_parser ("config" ,
81+ config = subparsers .add_parser ("config" , # pylint: disable=unused-variable
8382 help = "Validate and view the compose file" )
8483
8584 # Create (assumes built already), Up (will also build, if able)
@@ -110,10 +109,6 @@ def get_parser():
110109 shell = subparsers .add_parser ("shell" ,
111110 help = "shell into an instance" )
112111
113-
114- kill = subparsers .add_parser ("kill" ,
115- help = "kill instances" )
116-
117112 # Logs
118113
119114 logs = subparsers .add_parser ("logs" ,
@@ -127,33 +122,33 @@ def get_parser():
127122 help = "clear existing logs." ,
128123 default = False , action = 'store_true' )
129124
130- ps = subparsers .add_parser ("ps" ,
125+ ps = subparsers .add_parser ("ps" , # pylint: disable=unused-variable
131126 help = "list instances" )
132127
133128 restart = subparsers .add_parser ("restart" ,
134129 help = "stop and start containers." )
135130
136131 # Add list of names
137- for sub in [create , down , logs , up ]:
132+ for sub in [build , create , down , logs , up , restart ]:
138133 sub .add_argument ('names' , nargs = "*" ,
139134 help = 'the names of the instances to target' )
140135
141136 # Only one name allowed
142- for sub in [shell , execute , kill ]:
137+ for sub in [shell , execute ]:
143138 sub .add_argument ('name' , nargs = 1 ,
144139 help = 'the name of the instance to target' )
145140
146141 return parser
147142
148143
149- def main ():
144+ def start ():
150145 '''main is the entrypoint to singularity compose. We figure out the sub
151146 parser based on the command, and then import and call the appropriate
152147 main.
153148 '''
154149 parser = get_parser ()
155150
156- def help (return_code = 0 ):
151+ def show_help (return_code = 0 ):
157152 '''print help, including the software version and exit with return code
158153 '''
159154 version = scompose .__version__
@@ -164,34 +159,46 @@ def help(return_code=0):
164159
165160 # If the user didn't provide any arguments, show the full help
166161 if len (sys .argv ) == 1 :
167- help ()
162+ show_help ()
168163 try :
169164 args , extra = parser .parse_known_args ()
170165 except :
171166 sys .exit (0 )
172167
173- if args .verbose is False :
168+ if args .debug is True :
174169 os .environ ['MESSAGELEVEL' ] = "DEBUG"
175170 else :
176171 os .environ ['MESSAGELEVEL' ] = args .log_level
177172
173+ # Import the logger to grab verbosity level
174+ from scompose .logger import bot
175+
178176 # Show the version and exit
179177 if args .command == "version" or args .version is True :
180178 print (scompose .__version__ )
181179 sys .exit (0 )
182180
183181 # Does the user want a shell?
184- if args .command == "build" : from .build import main
185- elif args .command == "create" : from .create import main
186- elif args .command == "config" : from .config import main
187- elif args .command == "down" : from .down import main
188- elif args .command == "exec" : from .exec import main
189- elif args .command == "kill" : from .kill import main
190- elif args .command == "logs" : from .logs import main
191- elif args .command == "ps" : from .ps import main
192- elif args .command == "restart" : from .restart import main
193- elif args .command == "shell" : from .shell import main
194- elif args .command == "up" : from .up import main
182+ if args .command == "build" :
183+ from .build import main
184+ elif args .command == "create" :
185+ from .create import main
186+ elif args .command == "config" :
187+ from .config import main
188+ elif args .command == "down" :
189+ from .down import main
190+ elif args .command == "exec" :
191+ from .exec import main
192+ elif args .command == "logs" :
193+ from .logs import main
194+ elif args .command == "ps" :
195+ from .ps import main
196+ elif args .command == "restart" :
197+ from .restart import main
198+ elif args .command == "shell" :
199+ from .shell import main
200+ elif args .command == "up" :
201+ from .up import main
195202
196203 # Pass on to the correct parser
197204 return_code = 0
@@ -206,4 +213,4 @@ def help(return_code=0):
206213 sys .exit (return_code )
207214
208215if __name__ == '__main__' :
209- main ()
216+ start ()
0 commit comments