diff --git a/README.md b/README.md index 37c6ee9..bc78c23 100644 --- a/README.md +++ b/README.md @@ -65,6 +65,7 @@ The configuration file `~/.gitpassport` is rather self-explanatory: [general] enable_hook = True sleep_duration = 0.5 +quiet = False [passport 0] email = email_0@example.com @@ -77,6 +78,8 @@ name = name_1 service = gitlab.com ``` +Setting `quiet` to `True` will stop `git-passport.py` from printing the active passport upon default execution (To see the active passport with `quiet` enabled, you must pass the `-a` option). + Adjust the existing sections and add as many passports as you like by following the section scheme. diff --git a/git-passport.py b/git-passport.py index 172df2b..4e1cfb7 100755 --- a/git-passport.py +++ b/git-passport.py @@ -60,12 +60,13 @@ exit(0) if local_email and local_name: - case.active_identity( - config, - local_email, - local_name, - local_url - ) + if not config["quiet"]: + case.active_identity( + config, + local_email, + local_name, + local_url + ) sys.exit(0) if local_url: diff --git a/passport/configuration.py b/passport/configuration.py index 74f9a85..5c07154 100644 --- a/passport/configuration.py +++ b/passport/configuration.py @@ -32,6 +32,7 @@ def preset(filename): preset["general"] = {} preset["general"]["enable_hook"] = "True" preset["general"]["sleep_duration"] = "0.75" + preset["general"]["quiet"] = "False" preset["passport 0"] = {} preset["passport 0"]["email"] = "email_0@example.com" @@ -87,7 +88,8 @@ def validate_scheme(filename): "enable_hook", "name", "service", - "sleep_duration" + "sleep_duration", + "quiet" ]) # Create sets containing non-whitelisted section and option names @@ -148,6 +150,7 @@ def validate_values(filename): email: E-Mail scheme sleep_duration: Float enable_hook: Boolean + quiet: Boolean Args: filename (str): The complete `filepath` of the configuration file @@ -188,6 +191,14 @@ def filter_email(config): print(msg) return False + + try: + raw_config.getboolean("general", "quiet") + except ValueError: + msg = "E > Configuration > quiet: Expecting True or False." + + print(msg) + return False # Quit if we have wrong float values try: @@ -222,6 +233,7 @@ def passport(config): config = {} config["enable_hook"] = raw_config.getboolean("general", "enable_hook") + config["quiet"] = raw_config.getboolean("general", "quiet") config["sleep_duration"] = raw_config.getfloat("general", "sleep_duration") config["git_passports"] = dict(enumerate(passport(raw_config)))