Files
compiler-explorer/examples/spice/cli-parser.spice
Marc Auberer 54dda76f22 New language: Spice (#6105)
Add support for the Spice programming language.

Spice (`spicelang`) is a simple, AOT compiled, LLVM-based systems
language with focus on practicality and performance.

**Key features of Spice**
- simplicity - see what you get aproach with batteries included
- performance: As Spice uses LLVM as its primary backbone, it competes
with the performance of other LLVM-based compilers
- enhanced safety: Spice implements an enhanced safety mechanism, which
includes builtin heap type with auto-free and more
- cross-compile support: Currently x86_64, AArch64 and wasm32 are
supported cross-compilation targets, but more to come
- Pretty good C and C++ interop

**Links**
- Source code: https://github.com/spicelang/spice
- Website: https://spicelang.com
- Playground (own CE instance): https://play.spicelang.com
- Infra PR: https://github.com/compiler-explorer/infra/pull/1229

**Things this PR addresses**
- General support for Spice
- Three code examples
- Spice mode (Syntax highlighting)
- Opt pipeline support
- LLVM mca and osaca support
2024-02-12 21:50:33 -06:00

27 lines
752 B
Plaintext

import "std/io/cli-parser";
import "std/io/cli-subcommand";
type CliOptions struct {
string greetName = ""
}
p callback(bool& value) {
printf("Callback called with value %d\n", value);
}
f<int> main(int argc, string[] argv) {
CliParser parser = CliParser("Test Program", "This is a simple test program");
parser.setVersion("v0.1.0");
parser.setFooter("Copyright (c) Marc Auberer 2021-2024");
CliOptions options;
CliSubcommand& greet = parser.addSubcommand("greet", "Greet someone");
greet.addOption("--name", options.greetName, "Name of the person to greet");
parser.parse(argc, argv);
// Greet persion if requested
if options.greetName != "" {
printf("Hello %s!\n", options.greetName);
}
}