1313
1414
1515@click .group (invoke_without_command = True )
16+ @click .option (
17+ '--output' ,
18+ default = 'text' ,
19+ help = 'Specify the output (text/json), the default is text' ,
20+ type = click .Choice (['text' , 'json' ])
21+ )
1622@click .pass_context
17- def authenticate (context : click .Context ):
23+ def authenticate (context : click .Context , output : str ):
1824 """ Authenticates your machine to associate CLI with your cycode account """
1925 if context .invoked_subcommand is not None :
20- # if it is a subcommand do nothing
26+ context . obj [ 'output' ] = output
2127 return
2228
2329 try :
@@ -30,18 +36,12 @@ def authenticate(context: click.Context):
3036
3137
3238@authenticate .command (name = 'check' )
33- @click .option (
34- '--output' ,
35- default = 'text' ,
36- help = 'Specify the output (text/json), the default is text' ,
37- type = click .Choice (['text' , 'json' ])
38- )
3939@click .pass_context
40- def authorization_check (context : click .Context , output : str ):
40+ def authorization_check (context : click .Context ):
4141 """ Check your machine associating CLI with your cycode account """
4242 def print_result (* , result : bool ) -> None :
4343 # the current impl of printers supports only results of scans
44- if output == 'text' :
44+ if context . obj [ ' output' ] == 'text' :
4545 secho_args = {
4646 True : {'message' : 'You are authorized' , 'fg' : 'green' },
4747 False : {'message' : 'You are not authorized' , 'fg' : 'red' }
0 commit comments