Skip to content

Commit d028e18

Browse files
committed
feat: add --help for the cli
1 parent c654c98 commit d028e18

File tree

3 files changed

+42
-5
lines changed

3 files changed

+42
-5
lines changed

dist/main.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/main.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main.ts

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,18 @@ const inputs: Array<Inputs> = ["compiler", "architecture", ...tools]
6767
/** The main entry function */
6868
export async function main(args: string[]): Promise<number> {
6969
// parse options using mri or github actions
70-
const opts = mri<Record<Inputs, string | undefined>>(args, {
70+
const opts = mri<Record<Inputs, string | undefined> & { help: boolean }>(args, {
7171
string: inputs,
7272
default: Object.fromEntries(inputs.map((inp) => [inp, maybeGetInput(inp)])),
73+
alias: { h: "help" },
74+
boolean: "help",
7375
})
7476

77+
// print help
78+
if (opts.help) {
79+
printHelp()
80+
}
81+
7582
// cpu architecture
7683
const arch = opts.architecture ?? process.arch
7784

@@ -164,11 +171,10 @@ export async function main(args: string[]): Promise<number> {
164171
}
165172

166173
// report the messages in the end
167-
console.log("\n\n\n")
168174
successMessages.forEach((tool) => core.info(tool))
169175
errorMessages.forEach((tool) => core.error(tool))
170176

171-
core.info("install-cpp finished")
177+
core.info("setup-cpp finished")
172178
return errorMessages.length === 0 ? 0 : 1 // exit with non-zero if any error message
173179
}
174180
// Run main
@@ -182,6 +188,37 @@ main(process.argv)
182188
process.exitCode = 1
183189
})
184190

191+
function printHelp() {
192+
core.info(`
193+
setup-cpp [options]
194+
setup-cpp --compiler llvm --cmake true --ninja true --ccache true --conan "1.40.1"
195+
196+
Install all the tools required for building and testing C++/C projects.
197+
198+
--architecture\t the cpu architecture to install the tools for. By default it uses the current CPU architecture.
199+
--compiler\t the <compiler> to install.
200+
\t You can specify the version instead of specifying just the name e.g: --compiler 'llvm-11'
201+
202+
--tool_name\t pass "true" or pass the <version> you would like to install for this tool.
203+
204+
All the available tools:
205+
--llvm
206+
--gcc
207+
--cmake
208+
--ninja
209+
--meson
210+
--conan
211+
--ccache
212+
--cppcheck
213+
--doxygen
214+
--gcovr
215+
--opencppcoverage
216+
--python
217+
--choco
218+
--brew
219+
`)
220+
}
221+
185222
/** Get an object from github actions */
186223
function maybeGetInput(key: string) {
187224
const value = core.getInput(key.toLowerCase())

0 commit comments

Comments
 (0)