diff --git a/libervia/cli/base.py b/libervia/cli/base.py index 3abcda0b..1c74e4f3 100644 --- a/libervia/cli/base.py +++ b/libervia/cli/base.py @@ -71,6 +71,7 @@ class CLISettings(config.FrontendSettings, key="cli"): blog_preview_update_cmd: str | None = Field( default_factory=lambda data: data["blog_preview_open_cmd"] ) + verbosity: int = Field(default=0, description="Default verbosity level") try: @@ -273,10 +274,16 @@ class LiberviaCli: @property def verbosity(self): + """Output verbosity level. + + If verbosity is explicitly set with command arguments, it's used; otherwise, the + default verbosity from settings is used. + """ try: - return self.args.verbose + verbosity = self.args.verbose except AttributeError: - return 0 + verbosity = 0 + return verbosity or self.cli_settings.verbosity async def replay_cache(self, cache_attribute): """Replay cached signals @@ -294,13 +301,15 @@ class LiberviaCli: for cache_data in cache: await cache_data[0](*cache_data[1:]) - def disp(self, msg, verbosity=0, error=False, end="\n"): + def disp( + self, msg: str, verbosity: int = 0, error: bool = False, end: str = "\n" + ) -> None: """Print a message to user - @param msg(unicode): message to print - @param verbosity(int): minimal verbosity to display the message - @param error(bool): if True, print to stderr instead of stdout - @param end(str): string appended after the last value, default a newline + @param msg: message to print + @param verbosity: minimal verbosity to display the message + @param error: if True, print to stderr instead of stdout + @param end: string appended after the last value, default a newline """ if self.verbosity >= verbosity: if error: @@ -1284,6 +1293,7 @@ class CommandBase: @property def verbosity(self): + """Output verbosity level.""" return self.host.verbosity @property