11import click
2- from .config import pass_config , pass_validate , create_artifacts
2+ from .config import pass_config , pass_validate , create_artifacts , list_by_comma , print_pretty_json , is_docker
33from .profile import Profile
44from .secret import Secret
55
66
77@click .group ()
88@pass_config
9- @click .option ('--ci' , is_flag = True , help = "Use this flag to avoid deletion confirmation prompts" ) # noqa: E501
9+ @click .option ('--ci' , '-ci' , is_flag = True , help = "Use this flag to avoid deletion confirmation prompts" ) # noqa: E501
1010def cli (config , ci ):
1111 """All commands can run without providing options, and then you'll be prompted to insert values.\n
1212Secrets' values and Personal-Access-Tokens are hidden when prompted""" # noqa: E501
13+ if is_docker ():
14+ ci = True
1315 config .ci = ci # noqa: F821
1416
1517
@@ -33,9 +35,12 @@ def profile_apply(
3335 config , validate ,
3436 profile_name , github_owner , personal_access_token
3537):
36- """Create or modify a profile"""
38+ """Create or modify multiple profiles providing a string delimited by commas ","\n
39+ Example: ghs profile-apply -p 'willy, oompa'"""
3740 profile = Profile (config , profile_name )
38- profile .apply (github_owner , personal_access_token )
41+ profiles = list_by_comma (profile_name )
42+ for prof in profiles :
43+ profile .apply (github_owner , personal_access_token )
3944
4045
4146@cli .command ()
@@ -46,9 +51,12 @@ def profile_delete(
4651 config , validate ,
4752 profile_name
4853):
49- """Delete a profile"""
50- profile = Profile (config , profile_name )
51- profile .delete ()
54+ """Delete multiple profiles providing a string delimited by commas ","\n
55+ Example: ghs profile-delete -p 'willy, oompa'"""
56+ profile_names = list_by_comma (profile_name )
57+ for prof_name in profile_names :
58+ profile = Profile (config , prof_name )
59+ profile .delete ()
5260
5361
5462@cli .command ()
@@ -73,10 +81,16 @@ def secret_apply(
7381 config , validate ,
7482 repository , profile_name , secret_name , secret_value
7583):
76- """Create or modify a secret in a GitHub repository"""
84+ """Apply to multiple repositories providing a string delimited by commas ","\n
85+ Example: ghs secret-apply -p willy -r 'githubsecrets, serverless-template'"""
7786 profile = Profile (config , profile_name )
78- secret = Secret (config , profile , repository , secret_name , secret_value )
79- secret .apply ()
87+ repositories = list_by_comma (repository )
88+ responses = []
89+ for repo in repositories :
90+ secret = Secret (config , profile , repo , secret_name , secret_value )
91+ secret .apply ()
92+ responses .append (secret .apply ())
93+ print_pretty_json (responses )
8094
8195
8296@cli .command ()
@@ -89,10 +103,15 @@ def secret_delete(
89103 config , validate ,
90104 repository , profile_name , secret_name
91105):
92- """Delete a secret in a GitHub repository"""
106+ """Delete secrets from multiple repositories providing a string delimited by commas ","\n
107+ Example: ghs secret-delete -p willy -r 'githubsecrets, serverless-template'"""
93108 profile = Profile (config , profile_name )
94- secret = Secret (config , profile , repository , secret_name )
95- secret .delete ()
109+ repositories = list_by_comma (repository )
110+ responses = []
111+ for repo in repositories :
112+ secret = Secret (config , profile , repo , secret_name )
113+ responses .append (secret .delete ())
114+ print_pretty_json (responses )
96115
97116
98117@cli .command ()
@@ -105,10 +124,15 @@ def secret_get(
105124 config , validate ,
106125 repository , profile_name , secret_name
107126):
108- """Get a secret from a GitHub repository"""
127+ """Get secrets from multiple repositories providing a string delimited by commas ","\n
128+ Example: ghs secret-get -p willy -r 'githubsecrets, serverless-template'"""
109129 profile = Profile (config , profile_name )
110- secret = Secret (config , profile , repository , secret_name )
111- secret .get ()
130+ repositories = list_by_comma (repository )
131+ responses = []
132+ for repo in repositories :
133+ secret = Secret (config , profile , repo , secret_name )
134+ responses .append (secret .get ())
135+ print_pretty_json (responses )
112136
113137
114138@cli .command ()
@@ -120,7 +144,12 @@ def secret_list(
120144 config , validate ,
121145 repository , profile_name
122146):
123- """List all secret in a GitHub repository"""
147+ """List secrets of multiple repositories providing a string delimited by commas ","\n
148+ Example: ghs secret-delete -p willy -r 'githubsecrets, serverless-template'"""
124149 profile = Profile (config , profile_name )
125- secret = Secret (config , profile , repository )
126- secret .lista ()
150+ repositories = list_by_comma (repository )
151+ responses = []
152+ for repo in repositories :
153+ secret = Secret (config , profile , repo )
154+ responses .append (secret .lista ())
155+ print_pretty_json (responses )
0 commit comments