Oregami
Repositories/oxedyne/fe2o3

oxedyne/fe2o3/fe2o3_shield/src/app/syntax.rs

4.8 KiB, 21 runs

created by r1870400018:4074, which is this file's identity for as long as the history lasts, whatever it is later renamed to

download · who wrote it · its history

1//use crate::srv::id;
2
3use oxedyne_fe2o3_core::prelude::*;
4use oxedyne_fe2o3_jdat::{
5 prelude::*,
6 version::SemVer,
7};
8use oxedyne_fe2o3_syntax::{
9 self,
10 Syntax,
11 SyntaxRef,
12 arg::{
13 Arg,
14 ArgConfig,
15 },
16 cmd::{
17 Cmd,
18 CmdConfig,
19 },
20};
21
22
23pub fn new_shell(
24 name: &str,
25 ver: &SemVer,
26 about: &str,
27)
28 -> Outcome<SyntaxRef>
29{
30 let mut s = Syntax::new(name).ver(*ver).about(about);
31 s = res!(s.with_default_help_cmd());
32 s = res!(oxedyne_fe2o3_syntax::apps::file::generic_file_system(s));
33
34 // ┌───────────────────────┐
35 // │ CONTROL │
36 // └───────────────────────┘
37 // ---------------------------------------------------------------------------------------------
38 // Command: exit
39 // ---------------------------------------------------------------------------------------------
40 let cmd = Cmd::from(CmdConfig {
41 name: fmt!("exit"),
42 help: Some(fmt!("Shutdown the app and exit, or use Ctrl+C, Ctrl+D")),
43 cat: fmt!("Control"),
44 ..Default::default()
45 });
46 s = res!(s.add_cmd(cmd));
47 // =============================================================================================
48
49 // ---------------------------------------------------------------------------------------------
50 // Command: shell
51 // ---------------------------------------------------------------------------------------------
52 let cmd = Cmd::from(CmdConfig {
53 name: fmt!("shell"),
54 help: Some(fmt!("Start the app shell")),
55 cat: fmt!("Control"),
56 ..Default::default()
57 });
58 s = res!(s.add_cmd(cmd));
59 // =============================================================================================
60
61 // ---------------------------------------------------------------------------------------------
62 // Command: server
63 // ---------------------------------------------------------------------------------------------
64 let mut cmd = Cmd::from(CmdConfig {
65 name: fmt!("server"),
66 help: Some(fmt!("Start a UDP server instance")),
67 cat: fmt!("Control"),
68 ..Default::default()
69 });
70 let a1 = Arg::from(ArgConfig {
71 name: fmt!("test"),
72 hyph1: Some(fmt!("t")),
73 vals: vec![],
74 reqd: false,
75 help: Some(fmt!("Run server in test mode.")),
76 ..Default::default()
77 });
78 cmd = res!(cmd.add_arg(a1));
79 s = res!(s.add_cmd(cmd));
80
81 // ┌───────────────────────┐
82 // │ WALLET │
83 // └───────────────────────┘
84 // ---------------------------------------------------------------------------------------------
85 // Command: secrets
86 // ---------------------------------------------------------------------------------------------
87 let mut cmd = Cmd::from(CmdConfig {
88 name: fmt!("secrets"),
89 help: Some(fmt!("Manage wallet encrypted secrets.")),
90 cat: fmt!("Wallet"),
91 ..Default::default()
92 });
93 let a1 = Arg::from(ArgConfig {
94 name: fmt!("create"),
95 hyph1: Some(fmt!("c")),
96 vals: vec![(Kind::Str, fmt!("Name of secret for indexing")).into()],
97 reqd: false,
98 help: Some(fmt!("Interactively create a new encrypted secret.")),
99 ..Default::default()
100 });
101 let a2 = Arg::from(ArgConfig {
102 name: fmt!("recover"),
103 hyph1: Some(fmt!("r")),
104 vals: vec![(Kind::Str, fmt!("Name of secret for indexing")).into()],
105 reqd: false,
106 help: Some(fmt!("Interactively recover an encrypted secret.")),
107 ..Default::default()
108 });
109 cmd = res!(cmd.add_arg(a1));
110 cmd = res!(cmd.add_arg(a2));
111 s = res!(s.add_cmd(cmd));
112 // =============================================================================================
113
114 // ┌───────────────────────┐
115 // │ WORKSPACE │
116 // └───────────────────────┘
117 // ---------------------------------------------------------------------------------------------
118 // Command: vars
119 // ---------------------------------------------------------------------------------------------
120 let cmd = Cmd::from(CmdConfig {
121 name: fmt!("vars"),
122 help: Some(fmt!("Display variable names and values")),
123 cat: fmt!("Workspace"),
124 ..Default::default()
125 });
126 s = res!(s.add_cmd(cmd));
127 // =============================================================================================
128
129 Ok(SyntaxRef::new(s))
130}