Skip to content

Commit 295d409

Browse files
authored
tools.deploy: added parsing of command-line options (factor#3125)
* tools.deploy: added parsing of command-line options * tools.deploy: change documentation in --help to be more intuitive * tools.deploy: made a minor wording change to --help output
1 parent 5a72134 commit 295d409

File tree

6 files changed

+97
-2
lines changed

6 files changed

+97
-2
lines changed
File renamed without changes.
File renamed without changes.

basis/tools/deploy/deploy.factor

Lines changed: 97 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
! See https://factorcode.org/license.txt for BSD license.
33
USING: combinators command-line io.directories kernel namespaces
44
sequences system tools.deploy.backend tools.deploy.config
5-
tools.deploy.config.editor vocabs vocabs.loader ;
5+
tools.deploy.config.editor vocabs vocabs.loader command-line.parser math ;
66
IN: tools.deploy
77

88
ERROR: no-vocab-main vocab ;
@@ -30,6 +30,101 @@ ERROR: no-vocab-main vocab ;
3030
} cond require
3131

3232
: deploy-main ( -- )
33-
command-line get [ [ require ] [ deploy ] bi ] each ;
33+
"All boolean options above can be inverted by prefixing no- to the option name. for example, --console becomes --no-console" program-epilog set-global
34+
{
35+
T{ option
36+
{ name "--console" }
37+
{ required? f }
38+
{ #args 0 }
39+
{ help "If specified, enables the creation of a console application after deployment" }
40+
{ const t }
41+
{ variable deploy-console? }
42+
}
43+
T{ option
44+
{ name "--ui" }
45+
{ required? f }
46+
{ #args 0 }
47+
{ help "If specified, enables the the inclusion of the ui framework" }
48+
{ const t }
49+
{ variable deploy-ui? }
50+
}
51+
T{ option
52+
{ name "--unicode" }
53+
{ required? f }
54+
{ #args 0 }
55+
{ help "If specified, enables the the inclusion of full support for CHAR: " }
56+
{ const t }
57+
{ variable deploy-unicode? }
58+
}
59+
T{ option
60+
{ name "--strip-word-props" }
61+
{ required? f }
62+
{ #args 0 }
63+
{ help "If specified, enables the stripping of word properties the compiler thinks are unused" }
64+
{ const t }
65+
{ variable deploy-word-props? }
66+
}
67+
T{ option
68+
{ name "--keep-c-type-info" }
69+
{ required? f }
70+
{ #args 0 }
71+
{ help "If specified, disables the stripping of metadata for c types" }
72+
{ const t }
73+
{ variable deploy-c-types? }
74+
}
75+
T{ option
76+
{ name "--reflection" }
77+
{ required? f }
78+
{ meta "LEVEL" }
79+
{ #args 1 }
80+
{ type integer }
81+
{ validate [ [ 6 <= ] [ 0 > ] bi and ] }
82+
{ help "Sets the level of reflection that is required for the deployed executable. Must be an integer between 1 and 6 (inclusive). See the help for the deploy-reflection variable to learn more" }
83+
{ variable deploy-reflection }
84+
}
85+
T{ option
86+
{ name "--include-help" }
87+
{ required? f }
88+
{ #args 0 }
89+
{ help "If specified, enables the inclusion of documentation for all included words. This option is only helpful in a few niche situations, and shouldn't be used normally" }
90+
{ const t }
91+
{ variable deploy-help? }
92+
}
93+
T{ option
94+
{ name "--include-math" }
95+
{ required? f }
96+
{ #args 0 }
97+
{ help "If specified, enables the inclusion of ratio and complex number support. This option is only helpful in a few niche situations, and shouldn't be used normally" }
98+
{ const t }
99+
{ variable deploy-math? }
100+
}
101+
T{ option
102+
{ name "--include-threads" }
103+
{ required? f }
104+
{ #args 0 }
105+
{ help "If specified, enables the inclusion of thread support. This option is only helpful in a few niche situations, and shouldn't be used normally" }
106+
{ const t }
107+
{ variable deploy-threads? }
108+
}
109+
T{ option
110+
{ name "--io" }
111+
{ required? f }
112+
{ meta "LEVEL" }
113+
{ #args 1 }
114+
{ type integer }
115+
{ validate [ [ 3 <= ] [ 0 > ] bi and ] }
116+
{ help "Sets the level of io support required. Must be an integer between 1 and 3 (inclusive). See the help for the deploy-io variable to learn more. This option is only helpful in a few niche situations, and shouldn't be used normally" }
117+
{ variable deploy-io }
118+
}
119+
T{ option
120+
{ name "" }
121+
{ required? t }
122+
{ #args "+" }
123+
{ help "The vocabulary or vocabularies to be deployed" }
124+
{ variable "vocabs-to-deploy" }
125+
}
126+
}
127+
parse-options [ "vocabs-to-deploy" get [ [ require ] [ deploy ] bi ] each ] with-variables
128+
f program-epilog set-global ;
34129

35130
MAIN: deploy-main

0 commit comments

Comments
 (0)