Repository navigation
Expand file tree
/
Copy pathapps.py
More file actions
81 lines (72 loc) · 2.34 KB
/
Copy pathapps.py
File metadata and controls
81 lines (72 loc) · 2.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import argparse
from diffpy.apps.app_agentify import agentify
from diffpy.apps.app_runmacro import runmacro
from diffpy.apps.version import __version__ # noqa
class DiffpyHelpFormatter(argparse.RawDescriptionHelpFormatter):
"""Format subcommands without showing an extra placeholder entry."""
def _format_action(self, action):
if isinstance(action, argparse._SubParsersAction):
return "".join(
self._format_action(subaction)
for subaction in self._iter_indented_subactions(action)
)
return super()._format_action(action)
def main():
parser = argparse.ArgumentParser(
prog="diffpy.apps",
description=(
"User applications to help with tasks using diffpy packages\n\n"
"For more information, visit: "
"https://github.com/diffpy/diffpy.apps/"
),
formatter_class=DiffpyHelpFormatter,
)
parser.add_argument(
"--version",
action="version",
version=f"diffpy.apps {__version__}",
)
apps_parsers = parser.add_subparsers(
title="Available applications",
dest="application",
)
# runmacro application
runmacro_parser = apps_parsers.add_parser(
"runmacro",
help="Run a macro `<.dp-in>` file",
)
runmacro_parser.add_argument(
"file",
type=str,
help="Path to the `<.dp-in>` macro file to be run",
)
runmacro_parser.set_defaults(func=runmacro)
# agentify application
agentify_parser = apps_parsers.add_parser(
"agentify",
help="Deploy diffpy.cmi agentic skills in the local environment.",
)
agentify_parser.add_argument(
"--agent",
help="The agent to use for the agentic skill.",
default="claude",
choices=["claude", "codex"],
)
agentify_parser.add_argument(
"--update",
action="store_true",
help="When set, update the existing agentic skill.",
)
agentify_parser.add_argument(
"--system",
action="store_true",
help="When set, deploy the agentic skill to the system directory.",
)
agentify_parser.set_defaults(func=agentify)
args = parser.parse_args()
if args.application is None:
parser.print_help()
else:
args.func(args)
if __name__ == "__main__":
main()