Skip to content

Commit

Permalink
Add icpon (indented cpon) output format
Browse files Browse the repository at this point in the history
  • Loading branch information
Fanda Vacek committed Oct 30, 2024
1 parent 960f106 commit 60116e4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "shvcall"
version = "3.3.2"
version = "3.4.0"
edition = "2021"

[features]
Expand Down
9 changes: 8 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ struct Opts {
/// Timeout in milliseconds, value 0 means wait forever.
#[arg(short, long, default_value = "5000")]
timeout: u64,
/// Output format: [ cpon | chainpack | simple | value | "Placeholders {PATH} {METHOD} {VALUE} in any number and combination in custom string." ]
/// Output format: [ cpon | icpon | chainpack | simple | value | "Placeholders {PATH} {METHOD} {VALUE} in any number and combination in custom string." ]
#[arg(short = 'o', long = "output-format", default_value = "cpon")]
output_format: String,
/// Create TCP tunnel, SSH like syntax, example: -L 2222:some.host.org:22
Expand All @@ -67,6 +67,7 @@ struct Opts {
}
enum OutputFormat {
Cpon,
CponIndented,
ChainPack,
Simple,
Value,
Expand All @@ -79,6 +80,7 @@ impl From<&str> for OutputFormat {
"simple" => Self::Simple,
"value" => Self::Value,
"cpon" => Self::Cpon,
"icpon" => Self::CponIndented,
_ => Self::Custom(value.to_string()),
}
}
Expand Down Expand Up @@ -220,6 +222,11 @@ async fn make_call(
s.push('\n');
s.as_bytes().to_owned()
}
OutputFormat::CponIndented => {
let mut s = resp.as_rpcvalue().to_cpon_indented("\t");
s.push('\n');
s.as_bytes().to_owned()
}
OutputFormat::ChainPack => resp.as_rpcvalue().to_chainpack().to_owned(),
OutputFormat::Simple => {
let s = if resp.is_request() {
Expand Down

0 comments on commit 60116e4

Please sign in to comment.