Add --status and --report flags

This commit is contained in:
Joscha 2021-05-23 22:41:59 +02:00
parent 27b5a8e490
commit edbd92dbbf
3 changed files with 26 additions and 0 deletions

View File

@ -39,11 +39,17 @@ def load_config(args: argparse.Namespace) -> Config:
def configure_logging_from_args(args: argparse.Namespace) -> None: def configure_logging_from_args(args: argparse.Namespace) -> None:
if args.explain is not None: if args.explain is not None:
log.output_explain = args.explain log.output_explain = args.explain
if args.status is not None:
log.output_status = args.status
if args.report is not None:
log.output_report = args.report
# We want to prevent any unnecessary output if we're printing the config to # We want to prevent any unnecessary output if we're printing the config to
# stdout, otherwise it would not be a valid config file. # stdout, otherwise it would not be a valid config file.
if args.dump_config == "-": if args.dump_config == "-":
log.output_explain = False log.output_explain = False
log.output_status = False
log.output_report = False
def configure_logging_from_config(args: argparse.Namespace, config: Config) -> None: def configure_logging_from_config(args: argparse.Namespace, config: Config) -> None:
@ -56,6 +62,10 @@ def configure_logging_from_config(args: argparse.Namespace, config: Config) -> N
try: try:
if args.explain is None: if args.explain is None:
log.output_explain = config.default_section.explain() log.output_explain = config.default_section.explain()
if args.status is None:
log.output_status = config.default_section.status()
if args.report is None:
log.output_report = config.default_section.report()
except ConfigOptionError as e: except ConfigOptionError as e:
log.error(str(e)) log.error(str(e))
exit(1) exit(1)

View File

@ -159,6 +159,16 @@ PARSER.add_argument(
action=BooleanOptionalAction, action=BooleanOptionalAction,
help="log and explain in detail what PFERD is doing" help="log and explain in detail what PFERD is doing"
) )
PARSER.add_argument(
"--status",
action=BooleanOptionalAction,
help="print status updates while PFERD is crawling"
)
PARSER.add_argument(
"--report",
action=BooleanOptionalAction,
help="print a report of all local changes before exiting"
)
def load_default_section( def load_default_section(

View File

@ -75,6 +75,12 @@ class DefaultSection(Section):
def explain(self) -> bool: def explain(self) -> bool:
return self.s.getboolean("explain", fallback=False) return self.s.getboolean("explain", fallback=False)
def status(self) -> bool:
return self.s.getboolean("status", fallback=True)
def report(self) -> bool:
return self.s.getboolean("report", fallback=True)
class Config: class Config:
@staticmethod @staticmethod