Skip to content

Commit 73b2054

Browse files
committed
use i8n strings for debug messages
1 parent 5f76b74 commit 73b2054

File tree

5 files changed

+75
-11
lines changed

5 files changed

+75
-11
lines changed

sshdconfig/Cargo.lock

Lines changed: 60 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sshdconfig/locales/en-us.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,19 @@ parseInt = "Parse Integer"
1414
registry = "Registry"
1515

1616
[get]
17+
debugSetting = "Get setting:"
1718
defaultShellCmdOptionMustBeString = "cmdOption must be a string"
1819
defaultShellEscapeArgsMustBe0Or1 = "'%{input}' must be a 0 or 1"
1920
defaultShellEscapeArgsMustBeDWord = "escapeArguments must be a DWord"
2021
defaultShellMustBeString = "shell must be a string"
2122
notImplemented = "get not yet implemented for Microsoft.OpenSSH.SSHD/sshd_config"
2223
windowsOnly = "Microsoft.OpenSSH.SSHD/Windows is only applicable to Windows"
2324

25+
[main]
26+
export = "Export"
27+
schema = "Schema command:"
28+
set = "Set command: '%{input}'"
29+
2430
[parser]
2531
failedToParse = "failed to parse: '%{input}'"
2632
failedToParseAsArray = "value is not an array"
@@ -32,8 +38,10 @@ invalidMultiArgNode = "multi-arg node '%{input}' is not valid"
3238
invalidValue = "operator is an invalid value for node"
3339
keyNotFound = "key '%{key}' not found"
3440
keyNotRepeatable = "key '%{key}' is not repeatable"
41+
keywordDebug = "Parsing keyword: '%{text}'"
3542
missingValueInChildNode = "missing value in child node: '%{input}'"
3643
missingKeyInChildNode = "missing key in child node: '%{input}'"
44+
valueDebug = "Parsed argument value:"
3745
unknownNode = "unknown node: '%{kind}'"
3846
unknownNodeType = "unknown node type: '%{node}'"
3947

sshdconfig/src/get.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use crate::error::SshdConfigError;
2020
///
2121
/// This function will return an error if the desired settings cannot be retrieved.
2222
pub fn invoke_get(setting: &Setting) -> Result<(), SshdConfigError> {
23-
debug!("Get setting: {:?}", setting);
23+
debug!("{}: {:?}", t!("get.debugSetting").to_string(), setting);
2424
match *setting {
2525
Setting::SshdConfig => Err(SshdConfigError::NotImplemented(t!("get.notImplemented").to_string())),
2626
Setting::WindowsGlobal => get_default_shell()

sshdconfig/src/main.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Licensed under the MIT License.
33

44
use clap::{Parser};
5-
use rust_i18n::i18n;
5+
use rust_i18n::{i18n, t};
66
use schemars::schema_for;
77
use std::process::exit;
88
use tracing::{debug, error};
@@ -35,15 +35,14 @@ fn main() {
3535

3636
let result = match &args.command {
3737
Command::Export => {
38-
debug!("Export command");
38+
debug!("{}", t!("main.export").to_string());
3939
invoke_export()
4040
},
4141
Command::Get { setting } => {
42-
debug!("Get command: setting={:?}", setting);
4342
invoke_get(setting)
4443
},
4544
Command::Schema { setting } => {
46-
debug!("Schema command: setting={:?}", setting);
45+
debug!("{}; {:?}", t!("main.schema").to_string(), setting);
4746
let schema = match setting {
4847
Setting::SshdConfig => {
4948
schema_for!(SshdConfigParser)
@@ -56,7 +55,7 @@ fn main() {
5655
Ok(())
5756
},
5857
Command::Set { input } => {
59-
debug!("Set command: input={}", input);
58+
debug!("{}", t!("main.set", input = input).to_string());
6059
invoke_set(input)
6160
},
6261
};

sshdconfig/src/parser.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ impl SshdConfigParser {
7878
t!("parser.failedToParseChildNode", input = input).to_string()
7979
));
8080
};
81-
debug!("Parsing keyword: {text}");
81+
debug!("{}", t!("parser.keywordDebug", text = text).to_string());
8282
if REPEATABLE_KEYWORDS.contains(&text) {
8383
is_repeatable = true;
8484
is_vec = true;
@@ -94,7 +94,7 @@ impl SshdConfigParser {
9494
}
9595
if node.kind() == "arguments" {
9696
value = parse_arguments_node(node, input, input_bytes, is_vec)?;
97-
debug!("Parsed argument value: {:?}", value);
97+
debug!("{}: {:?}", t!("parser.valueDebug").to_string(), value);
9898
}
9999
}
100100
if let Some(key) = key {

0 commit comments

Comments
 (0)