Skip to content

Commit

Permalink
feat: Corset code can be provided from STDIN
Browse files Browse the repository at this point in the history
  • Loading branch information
delehef committed Aug 28, 2023
1 parent e0939e4 commit 024dc11
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ path = "src/main.rs"

[dependencies]
anyhow = "1"
atty = "0.2.14"
buche = "0.7"
buildstructor = "0.5.2"
cached = { version = "0.43", default-features = false }
Expand Down
10 changes: 9 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,8 @@ impl ConstraintSetBuilder {

#[cfg(feature = "cli")]
fn main() -> Result<()> {
use std::io::{self, Read};

let args = Args::parse();
buche::new()
.verbosity(args.verbose.log_level_filter())
Expand All @@ -434,7 +436,13 @@ fn main() -> Result<()> {
.unwrap();

let mut builder = if cfg!(feature = "parser") {
if matches!(args.command, Commands::Format { .. }) {
if !atty::is(atty::Stream::Stdin) {
let mut r = ConstraintSetBuilder::from_sources(args.no_stdlib, args.debug);
let mut input = String::new();
io::stdin().read_to_string(&mut input)?;
r.add_source(&input)?;
r
} else if matches!(args.command, Commands::Format { .. }) {
if args.source.len() != 1 {
bail!("can only format one file at a time")
} else if args.source.len() == 1
Expand Down

0 comments on commit 024dc11

Please sign in to comment.