Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/spk-cli/group4/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ itertools = { workspace = true }
spfs = { workspace = true }
spk-cli-common = { workspace = true }
spk-cli-group2 = { workspace = true }
spk-config = { workspace = true }
spk-schema = { workspace = true }
spk-solve = { workspace = true }
spk-storage = { workspace = true }
Expand Down
30 changes: 30 additions & 0 deletions crates/spk-cli/group4/src/cmd_config.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Copyright (c) Contributors to the SPK project.
// SPDX-License-Identifier: Apache-2.0
// https://github.com/spkenv/spk

use clap::Args;
use miette::{IntoDiagnostic, Result};
use spk_cli_common::{CommandArgs, Run};

/// Output the current configuration of spk
#[derive(Args)]
pub struct Config {}

#[async_trait::async_trait]
impl Run for Config {
type Output = i32;

async fn run(&mut self) -> Result<Self::Output> {
let config = spk_config::get_config()?;
let out = serde_json::to_string_pretty(&*config).into_diagnostic()?;
println!("{out}");
Ok(0)
}
}

impl CommandArgs for Config {
fn get_positional_args(&self) -> Vec<String> {
// There are no important positional args for a config command
vec![]
}
}
1 change: 1 addition & 0 deletions crates/spk-cli/group4/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// SPDX-License-Identifier: Apache-2.0
// https://github.com/spkenv/spk

pub mod cmd_config;
pub mod cmd_lint;
pub mod cmd_search;
pub mod cmd_version;
Expand Down
5 changes: 4 additions & 1 deletion crates/spk/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use spk_cli_common::{CommandArgs, Error, Run, configure_logging};
use spk_cli_group1::{cmd_bake, cmd_completion, cmd_deprecate, cmd_undeprecate};
use spk_cli_group2::{cmd_ls, cmd_new, cmd_num_variants, cmd_publish, cmd_remove, cmd_stats};
use spk_cli_group3::{cmd_export, cmd_import};
use spk_cli_group4::{cmd_lint, cmd_search, cmd_version, cmd_view};
use spk_cli_group4::{cmd_config, cmd_lint, cmd_search, cmd_version, cmd_view};
use spk_cmd_build::cmd_build;
use spk_cmd_convert::cmd_convert;
use spk_cmd_debug::cmd_debug;
Expand Down Expand Up @@ -160,6 +160,7 @@ pub enum Command {
Bake(cmd_bake::Bake),
Build(cmd_build::Build),
Completion(cmd_completion::Completion),
Config(cmd_config::Config),
Convert(cmd_convert::Convert),
Debug(cmd_debug::Debug),
Deprecate(cmd_deprecate::DeprecateCmd),
Expand Down Expand Up @@ -201,6 +202,7 @@ impl Run for Command {
Command::Bake(cmd) => cmd.run().await,
Command::Build(cmd) => cmd.run().await.map(Into::into),
Command::Completion(cmd) => cmd.run(Opt::command()),
Command::Config(cmd) => cmd.run().await,
Command::Convert(cmd) => cmd.run().await,
Command::Debug(cmd) => cmd.run().await,
Command::Deprecate(cmd) => cmd.run().await,
Expand Down Expand Up @@ -238,6 +240,7 @@ impl CommandArgs for Command {
Command::Build(cmd) => cmd.get_positional_args(),
Command::Convert(cmd) => cmd.get_positional_args(),
Command::Completion(cmd) => cmd.get_positional_args(),
Command::Config(cmd) => cmd.get_positional_args(),
Command::Debug(cmd) => cmd.get_positional_args(),
Command::Deprecate(cmd) => cmd.get_positional_args(),
Command::Du(cmd) => cmd.get_positional_args(),
Expand Down
5 changes: 5 additions & 0 deletions docs/admin/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ For spk: `/etc/spk.toml`, which can be overridden by `~/.config/spk/spk.toml`

All spfs and spk configuration values can be overridden in the environment. The name of the variable will be the upper-cased name of the config value, separated by underscores, and prefixed with either `SPFS_` or `SPK_`, eg: `SPFS_STORAGE_ROOT`. In cases where the name of the config value contains an underscore, two underscores can be used to disambiguate separators from names, eg: `SPFS_STORAGE__TAG_NAMESPACE`.

### Viewing the Current Configuration

The effective configuration, after all files and environment variables have been
loaded, can be printed as json with the `spfs config` and `spk config` commands.

### SPFS Configuration

```toml
Expand Down
Loading