Command-line interface for the whole development cycle of CyberFabric projects.
- Rust toolchain with
cargo(https://rust-lang.org/tools/install/)
Install it from the repository root:
cargo install --git https://github.com/cyberfabric/cf-cliAfter installation, you can check for:
cargo cyberfabric --helpFirst you can create a new workspace with a basic hello-world module with:
cargo cyberfabric init /tmp/cf-demoYou can run it straight away and you will see in the console a hello world message:
cd /tmp/cf-demo
cargo cyberfabric run -c ./config/quickstart.ymlThe generated server reads its config path from the CF_CLI_CONFIG environment variable. cargo cyberfabric build and
cargo cyberfabric run set this automatically for the generated project.
Second, add a module to the workspace. You can choose among a set of templates: background-worker, api-db-handler,
and rest-gateway. For this example we'll use background-worker:
# bring the module to the workspace
cargo cyberfabric mod add background-worker
# add the module to the config
cargo cyberfabric config mod add background-worker -c ./config/quickstart.ymlNow, we run it again. We'll see every couple of seconds, the background worker printing a random Pokémon:
cargo cyberfabric run -c ./config/quickstart.ymlYou can run the tool from any directory by specifying the path to the workspace with the -p flag. The default will be
the current directory. cargo cyberfabric run -p /tmp/cf-demo -c /tmp/cf-demo/config/quickstart.yml
The current CLI surface is centered on CyberFabric workspace setup, configuration, code generation, and execution.
initinitializes a new CyberFabric workspace from a templatemod addadds module templates such asbackground-worker,api-db-handler, andrest-gateway
config mod listinspects available and configured modulesconfig mod addandconfig mod rmmanage module entries in the YAML configconfig mod db add|edit|rmmanages module-level database settingsconfig db add|edit|rmmanages shared database server definitions
You need to provide the path to the configuration file with the -c flag. -c config/quickstart.yml
buildgenerates a runnable Cargo project under.cyberfabric/<CONFIG_NAME>and builds it based on the-cconfiguration provided.rungenerates the same project and runs it. You can provide-wto enable watch mode,--otelto enable OpenTelemetry, and--fipsto enable the generated manifest'sfipsfeature.buildandrunboth pass--oteland--fipsthrough as Cargo features on the generated project manifest.
The generated src/main.rs does not embed the config path. Instead, the generated server reads it from
CF_CLI_CONFIG at runtime. The CLI sets that variable for build and run, but if you execute .cyberfabric/<name>/
or the compiled binary yourself, you need to set CF_CLI_CONFIG manually.
Example manual run of the generated project:
CF_CLI_CONFIG=/tmp/cf-demo/config/quickstart.yml cargo run --manifest-path /tmp/cf-demo/.cyberfabric/quickstart/Cargo.tomldocsresolves Rust source for crates, modules, and items from the workspace, local cache, orcrates.io
cargo cyberfabric lint defaults to running all available lint suites for the current or selected workspace. It
orchestrates
cargo fmt cargo clippy and dylint custom rules. It respects your custom settings from Cargo.toml.
If the CLI is built without the dylint-rules feature, lint --dylint returns an error.
toolsinstalls or upgradesrustup,rustfmt, andclippy
testis declared but not implemented yet
For the full command surface, arguments, and examples, check SKILLS.md.
To run the CLI from source:
cargo run -p cli -- --helpThis project is licensed under the Apache License, Version 2.0.
- Full license text: LICENSE
- License URL: http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, the software is distributed on an AS IS basis, without
warranties or conditions of any kind.