Skip to content

Commit

Permalink
make --no-header an additional argument to --csv
Browse files Browse the repository at this point in the history
Instead of combining the argument as `--csv-no-header`, make `--no-header` an additional flag for `--csv`.

For example: `pqrs cat --csv --no-header parquetFile`
  • Loading branch information
Jeffrey Barczewski committed Aug 2, 2022
1 parent 89179ee commit beb7187
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ foo,bar
```

```shell
❯ pqrs cat data/simple.parquet --csv-no-header
❯ pqrs cat data/simple.parquet --csv --no-header
1,2
10,20
```
Expand Down
10 changes: 5 additions & 5 deletions src/commands/cat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ use walkdir::WalkDir;
#[derive(Parser, Debug)]
pub struct CatCommandArgs {
/// Use CSV format for printing
#[clap(short, long, conflicts_with_all = &["csv-no-header","json"])]
#[clap(short, long, conflicts_with = "json")]
csv: bool,

/// Use CSV format without a header for printing
#[clap(long = "csv-no-header", conflicts_with_all = &["csv","json"])]
#[clap(long = "no-header", requires = "csv", conflicts_with = "json")]
csv_no_header: bool,

/// Use JSON lines format for printing
#[clap(short, long, conflicts_with_all = &["csv", "csv-no-header"])]
#[clap(short, long, conflicts_with = "csv")]
json: bool,

/// Parquet files or folders to read from
Expand All @@ -31,10 +31,10 @@ pub struct CatCommandArgs {
pub(crate) fn execute(opts: CatCommandArgs) -> Result<(), PQRSError> {
let format = if opts.json {
Formats::Json
} else if opts.csv {
Formats::Csv
} else if opts.csv_no_header {
Formats::CsvNoHeader
} else if opts.csv {
Formats::Csv
} else {
Formats::Default
};
Expand Down
3 changes: 2 additions & 1 deletion tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ mod integration {
let mut cmd = Command::cargo_bin("pqrs")?;
cmd.arg("cat")
.arg(SIMPLE_PARQUET_PATH)
.arg("--csv-no-header");
.arg("--csv")
.arg("--no-header");
cmd.assert()
.success()
.stdout(predicate::str::starts_with(CAT_CSV_NO_HEADER_OUTPUT));
Expand Down

0 comments on commit beb7187

Please sign in to comment.