Skip to content

Commit 875f2fe

Browse files
committed
Add 'config show' command
1 parent 9af3681 commit 875f2fe

File tree

3 files changed

+36
-1
lines changed

3 files changed

+36
-1
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
This can be used to satisfy the `<base>` and `<game>` path placeholders
99
in cases where Ludusavi can't automatically detect the right folder.
1010
For more info, [see the custom games document](/docs/help/custom-games.md).
11+
* CLI: `config show` command.
1112
* CLI: The `backup`, `restore`, `cloud upload`, and `cloud download` commands
1213
now support a `--gui` option for graphical dialog prompts.
1314
* CLI: The `backup` and `restore` commands now support a `--dump-registry` option,

src/cli.rs

+14-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use rayon::{
1414

1515
use crate::{
1616
cli::{
17-
parse::{Cli, CompletionShell, ManifestSubcommand, Subcommand},
17+
parse::{Cli, CompletionShell, ConfigSubcommand, ManifestSubcommand, Subcommand},
1818
report::{report_cloud_changes, Reporter},
1919
},
2020
cloud::{CloudChange, Rclone, Remote},
@@ -664,6 +664,19 @@ pub fn run(sub: Subcommand, no_manifest_update: bool, try_manifest_update: bool)
664664
Manifest::update_mut(&config, &mut cache, force)?;
665665
}
666666
},
667+
Subcommand::Config { sub: config_sub } => match config_sub {
668+
ConfigSubcommand::Show { api, default } => {
669+
if default {
670+
config = Config::default();
671+
}
672+
673+
if api {
674+
println!("{}", serde_json::to_string(&config).unwrap());
675+
} else {
676+
println!("{}", serde_yaml::to_string(&config).unwrap());
677+
}
678+
}
679+
},
667680
Subcommand::Cloud { sub: cloud_sub } => match cloud_sub {
668681
parse::CloudSubcommand::Set { sub } => match sub {
669682
parse::CloudSetSubcommand::None => {

src/cli/parse.rs

+21
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,11 @@ pub enum Subcommand {
365365
#[clap(subcommand)]
366366
sub: ManifestSubcommand,
367367
},
368+
/// Options for Ludusavi's configuration.
369+
Config {
370+
#[clap(subcommand)]
371+
sub: ConfigSubcommand,
372+
},
368373
/// Cloud sync.
369374
Cloud {
370375
#[clap(subcommand)]
@@ -427,6 +432,7 @@ impl Subcommand {
427432
Self::Backups { .. } => false,
428433
Self::Find { .. } => false,
429434
Self::Manifest { .. } => false,
435+
Self::Config { .. } => false,
430436
Self::Cloud { sub } => sub.force(),
431437
Self::Wrap { force, .. } => *force,
432438
Self::Api { .. } => false,
@@ -442,6 +448,7 @@ impl Subcommand {
442448
Self::Backups { .. } => false,
443449
Self::Find { .. } => false,
444450
Self::Manifest { .. } => false,
451+
Self::Config { .. } => false,
445452
Self::Cloud { sub } => sub.gui(),
446453
Self::Wrap { gui, .. } => *gui,
447454
Self::Api { .. } => false,
@@ -467,6 +474,20 @@ pub enum ManifestSubcommand {
467474
},
468475
}
469476

477+
#[derive(clap::Subcommand, Clone, Debug, PartialEq, Eq)]
478+
pub enum ConfigSubcommand {
479+
/// Print the active configuration.
480+
Show {
481+
/// Print information to stdout in machine-readable JSON.
482+
#[clap(long)]
483+
api: bool,
484+
485+
/// Print the default configuration.
486+
#[clap(long)]
487+
default: bool,
488+
},
489+
}
490+
470491
#[derive(clap::Subcommand, Clone, Debug, PartialEq, Eq)]
471492
pub enum CloudSubcommand {
472493
/// Configure the cloud system to use.

0 commit comments

Comments
 (0)