[PATCH 3/4] dts: show help when DTS is ran without args
    Luca Vizzarro 
    luca.vizzarro at arm.com
       
    Mon Jan 22 19:26:10 CET 2024
    
    
  
This commit changes the default behaviour of DTS, making it so that the
user automatically sees the help and usage page when running it without
any arguments set. Instead of being welcomed by an error message.
Reviewed-by: Paul Szczepanek <paul.szczepanek at arm.com>
Signed-off-by: Luca Vizzarro <luca.vizzarro at arm.com>
---
 dts/framework/settings.py | 6 ++++++
 1 file changed, 6 insertions(+)
diff --git a/dts/framework/settings.py b/dts/framework/settings.py
index acfe5cad44..5809fd4e91 100644
--- a/dts/framework/settings.py
+++ b/dts/framework/settings.py
@@ -71,6 +71,7 @@
 
 import argparse
 import os
+import sys
 from collections.abc import Callable, Iterable, Sequence
 from dataclasses import dataclass, field
 from pathlib import Path
@@ -315,6 +316,11 @@ def get_settings() -> Settings:
 
     The inputs are taken from the command line and from environment variables.
     """
+
+    if len(sys.argv) == 1:
+        _get_parser().print_help()
+        sys.exit(1)
+
     parsed_args = _get_parser().parse_args()
     return Settings(
         config_file_path=parsed_args.config_file,
-- 
2.34.1
    
    
More information about the dev
mailing list