File tree Expand file tree Collapse file tree 2 files changed +8
-3
lines changed Expand file tree Collapse file tree 2 files changed +8
-3
lines changed Original file line number Diff line number Diff line change 8
8
- Added basic example program about how to import a dashboard
9
9
- Options: Permitted usage without authentication credentials or token
10
10
- Options: Do not assume defaults for ` ACTION ` and ` --grafana_label ` args
11
+ - Options: Print help text when using erroneous parameters
11
12
12
13
## 0.4.0 (2024-10-16)
13
14
- Fixed folder argument issue
Original file line number Diff line number Diff line change @@ -97,6 +97,10 @@ def main():
97
97
# Get command line arguments.
98
98
parser = argparse .ArgumentParser (description = "play with grafana dashboards json files." )
99
99
100
+ def print_help_and_exit ():
101
+ parser .print_help (sys .stderr )
102
+ parser .exit (1 )
103
+
100
104
parser .add_argument (
101
105
"-a" ,
102
106
"--allow_new" ,
@@ -235,8 +239,8 @@ def main():
235
239
236
240
try :
237
241
grafana_api = Grafana .Grafana (** params )
238
- except Exception as e :
239
- logger .error (f"ERROR: { e } " )
242
+ except Exception as ex :
243
+ logger .error (str ( ex ) )
240
244
sys .exit (1 )
241
245
242
246
# Import
@@ -347,7 +351,7 @@ def process_dashboard(file_path):
347
351
348
352
else :
349
353
logger .error (f"Unknown action: { args .action } . Use one of: { parser ._actions [- 2 ].choices } " )
350
- sys . exit ( 1 )
354
+ print_help_and_exit ( )
351
355
352
356
353
357
if __name__ == "__main__" :
You can’t perform that action at this time.
0 commit comments