Skip to content

Commit f597444

Browse files
committed
rename enum for clarity
1 parent e2d244c commit f597444

File tree

7 files changed

+26
-25
lines changed

7 files changed

+26
-25
lines changed

sshdconfig/src/args.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ pub struct Args {
1616
pub enum Command {
1717
/// Get default shell, eventually to be used for `sshd_config` and repeatable keywords
1818
Get {
19-
#[clap(short = 'r', long, hide = true)]
20-
resource: Resource,
19+
#[clap(short = 's', long, hide = true)]
20+
setting: Setting,
2121
},
2222
/// Set default shell, eventually to be used for `sshd_config` and repeatable keywords
2323
Set {
@@ -28,8 +28,8 @@ pub enum Command {
2828
Export,
2929
Schema {
3030
// Used to inform which schema to generate
31-
#[clap(short = 'r', long, hide = true)]
32-
resource: Resource,
31+
#[clap(short = 's', long, hide = true)]
32+
setting: Setting,
3333
},
3434
}
3535

@@ -41,7 +41,7 @@ pub struct DefaultShell {
4141
}
4242

4343
#[derive(Clone, Debug, Eq, PartialEq, ValueEnum)]
44-
pub enum Resource {
44+
pub enum Setting {
4545
SshdConfig,
4646
WindowsGlobal
4747
}

sshdconfig/src/get.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44
#[cfg(windows)]
55
use {
66
registry_lib::{config::{Registry, RegistryValueData}, RegistryHelper},
7-
crate::args::{DefaultShell, Resource},
7+
crate::args::DefaultShell,
88
crate::metadata::{DEFAULT_SHELL, DEFAULT_SHELL_CMD_OPTION, DEFAULT_SHELL_ESCAPE_ARGS, REGISTRY_PATH},
99
};
1010

11+
use crate::args::Setting;
1112
use crate::error::SshdConfigError;
1213
use rust_i18n::t;
1314

@@ -16,10 +17,10 @@ use rust_i18n::t;
1617
/// # Errors
1718
///
1819
/// This function will return an error if the desired settings cannot be retrieved.
19-
pub fn invoke_get(resource: &Resource) -> Result<(), SshdConfigError> {
20-
match *resource {
21-
Resource::SshdConfig => Err(SshdConfigError::NotImplemented(t!("get.notImplemented").to_string())),
22-
Resource::WindowsGlobal => get_default_shell()
20+
pub fn invoke_get(setting: &Setting) -> Result<(), SshdConfigError> {
21+
match *setting {
22+
Setting::SshdConfig => Err(SshdConfigError::NotImplemented(t!("get.notImplemented").to_string())),
23+
Setting::WindowsGlobal => get_default_shell()
2324
}
2425
}
2526

sshdconfig/src/main.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use clap::{Parser};
55
use rust_i18n::i18n;
66
use schemars::schema_for;
77

8-
use args::{Args, Command, DefaultShell, Resource};
8+
use args::{Args, Command, DefaultShell, Setting};
99
use export::invoke_export;
1010
use get::invoke_get;
1111
use parser::SshdConfigParser;
@@ -27,14 +27,14 @@ fn main() {
2727

2828
let result = match &args.command {
2929
Command::Export => invoke_export(),
30-
Command::Get { resource } => invoke_get(resource),
30+
Command::Get { setting } => invoke_get(setting),
3131
Command::Set { input } => invoke_set(input),
32-
Command::Schema { resource } => {
33-
let schema = match resource {
34-
Resource::SshdConfig => {
32+
Command::Schema { setting } => {
33+
let schema = match setting {
34+
Setting::SshdConfig => {
3535
schema_for!(SshdConfigParser)
3636
},
37-
Resource::WindowsGlobal => {
37+
Setting::WindowsGlobal => {
3838
schema_for!(DefaultShell)
3939
}
4040
};

sshdconfig/src/set.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ fn set_default_shell(shell: Option<String>, cmd_option: Option<String>, escape_a
6767

6868
#[cfg(not(windows))]
6969
fn set_default_shell(_shell: Option<String>, _cmd_option: Option<String>, _escape_arguments: Option<bool>) -> Result<(), SshdConfigError> {
70-
Err(SshdConfigError::InvalidInput(t!("get.windowsOnly")))
70+
Err(SshdConfigError::InvalidInput(t!("get.windowsOnly").to_string()))
7171
}
7272

7373
#[cfg(windows)]

sshdconfig/sshd.dsc.resource.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"executable": "sshdconfig",
1111
"args": [
1212
"get",
13-
"-r",
13+
"-s",
1414
"windows-global"
1515
]
1616
},
@@ -29,7 +29,7 @@
2929
"executable": "sshdconfig",
3030
"args": [
3131
"schema",
32-
"-r",
32+
"-s",
3333
"windows-global"
3434
]
3535
}

sshdconfig/sshd_config.dsc.resource.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"executable": "sshdconfig",
1515
"args": [
1616
"schema",
17-
"-r",
17+
"-s",
1818
"sshd-config"
1919
]
2020
}

sshdconfig/tests/defaultshell.tests.ps1

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ Describe 'Default Shell Configuration Tests' -Skip:(!$IsWindows) {
6262
$testShell = "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe"
6363
New-ItemProperty -Path $RegistryPath -Name "DefaultShell" -Value $testShell
6464

65-
$output = sshdconfig get -r windows-global
65+
$output = sshdconfig get -s windows-global
6666
$LASTEXITCODE | Should -Be 0
6767

6868
$result = $output | ConvertFrom-Json
@@ -78,7 +78,7 @@ Describe 'Default Shell Configuration Tests' -Skip:(!$IsWindows) {
7878
New-ItemProperty -Path $RegistryPath -Name "DefaultShellCommandOption" -Value "/c"
7979
New-ItemProperty -Path $RegistryPath -Name "DefaultShellEscapeArguments" -Value 0 -Type DWord
8080

81-
$output = sshdconfig get -r windows-global
81+
$output = sshdconfig get -s windows-global
8282
$LASTEXITCODE | Should -Be 0
8383

8484
$result = $output | ConvertFrom-Json
@@ -88,7 +88,7 @@ Describe 'Default Shell Configuration Tests' -Skip:(!$IsWindows) {
8888
}
8989

9090
It 'Should handle empty default shell registry values' -Skip:(!$IsWindows) {
91-
$output = sshdconfig get -r windows-global
91+
$output = sshdconfig get -s windows-global
9292
$LASTEXITCODE | Should -Be 0
9393

9494
$result = $output | ConvertFrom-Json
@@ -165,7 +165,7 @@ Describe 'Default Shell Configuration Tests' -Skip:(!$IsWindows) {
165165
sshdconfig set --input $inputJson
166166
$LASTEXITCODE | Should -Be 0
167167

168-
$getOutput = sshdconfig get -r windows-global
168+
$getOutput = sshdconfig get -s windows-global
169169
$LASTEXITCODE | Should -Be 0
170170

171171
$retrievedConfig = $getOutput | ConvertFrom-Json
@@ -202,7 +202,7 @@ Describe 'Default Shell Configuration Error Handling on Non-Windows Platforms' -
202202
}
203203

204204
It 'Should return error for get command' {
205-
$out = sshdconfig get -r windows-global 2>&1
205+
$out = sshdconfig get -s windows-global 2>&1
206206
$LASTEXITCODE | Should -Not -Be 0
207207
$out | Should -BeLike '*not applicable to this platform*'
208208
}

0 commit comments

Comments
 (0)