Entry point for the ActionFlow CLI.
This function sets up the command-line interface (CLI) for the ActionFlow tool.
It defines three subcommands: 'run', 'logs', and 'status'.
Subcommands:
- run: Run the main process with the specified file.
Arguments:
filepath (str): Path to the file to be processed.
-v, --verbose (bool): Enable verbose output.
- logs: Fetch logs.
- status: Fetch current status.
Parses the command-line arguments and calls the appropriate function based on the subcommand.
If no valid subcommand is provided, it prints the help message and exits with status code 1.
Source code in actionflow/cli.py
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111 | def main():
"""
Entry point for the ActionFlow CLI.
This function sets up the command-line interface (CLI) for the ActionFlow tool.
It defines three subcommands: 'run', 'logs', and 'status'.
Subcommands:
- run: Run the main process with the specified file.
Arguments:
filepath (str): Path to the file to be processed.
-v, --verbose (bool): Enable verbose output.
- logs: Fetch logs.
- status: Fetch current status.
Parses the command-line arguments and calls the appropriate function based on the subcommand.
If no valid subcommand is provided, it prints the help message and exits with status code 1.
"""
parser = argparse.ArgumentParser(description="ActionFlow CLI")
subparsers = parser.add_subparsers(dest="command", help="Available commands")
run_parser = subparsers.add_parser("run", help="Run the main process")
run_parser.add_argument(
"filepath", type=str, help="Path to the file to be processed"
)
run_parser.add_argument(
"-v", "--verbose", action="store_true", help="Enable verbose output"
)
logs_parser = subparsers.add_parser("logs", help="Fetch logs")
status_parser = subparsers.add_parser("status", help="Fetch current status")
args = parser.parse_args()
if args.command == "run":
run(args.filepath, args.verbose)
elif args.command == "logs":
logs()
elif args.command == "status":
status()
else:
parser.print_help()
sys.exit(1)
|