Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for --raw/-r #23

Merged
merged 3 commits into from
Jan 19, 2025
Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
run: curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash

- name: Install tq
run: cargo binstall -y tomlq
run: cargo binstall -y tomlq@0.1.6
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a left over used to test right?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this is used to make sure there's no problems with the actual release of this version. After doing the release I'll be unpinning it


- id: get-version
name: Output the current version of the project
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "tomlq"
version = "0.2.1"
version = "0.2.2"
authors = [
"Natalia Maximo <[email protected]>",
"James Munns <[email protected]>",
Expand Down
14 changes: 12 additions & 2 deletions src/bin/tq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ struct Cli {
#[arg(short, long, default_value = "toml")]
pub output: Format,

/// Should the output be raw? Only applies to TOML output.
#[arg(short, long)]
pub raw: bool,

/// The input type. Default is TOML, but supports inputting in different formats. If the input
/// is JSON, it will be converted to TOML. So there is an overhead of using JSON input.
#[arg(short, long, default_value = "toml")]
Expand Down Expand Up @@ -105,7 +109,7 @@ fn main() -> anyhow::Result<()> {
};

#[cfg(feature = "syntax-highlighting")]
{
if !app.raw {
// If the syntax-highlighting crate feature is enabled, use `bat`'s pretty printing system to print with
// highlighting. This will not restructure code/lines, and does not override the --pretty flag.
let mut pretty_printer = bat::PrettyPrinter::new();
Expand All @@ -132,11 +136,17 @@ fn main() -> anyhow::Result<()> {
.print()?;
}
}
} else {
println!("{}", output.trim_matches('"'));
}

// If there is not syntax highlighting, just print normally.
#[cfg(not(feature = "syntax-highlighting"))]
println!("{output}");
if !app.raw {
println!("{output}");
} else {
println!("{}", output.trim_matches('"'));
}

Ok(())
}
Loading