Skip to content

Commit

Permalink
positional arg
Browse files Browse the repository at this point in the history
  • Loading branch information
scx1332 committed Jul 19, 2024
1 parent bc743a0 commit 61e9780
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Prepare test file
run: |
cat-once --file test.file --test-create-ascii-file-size=1000000000
cat-once test.file --test-create-ascii-file-size=1000000000
sha1sum test.file > test-in.file.sha1
tar -cf - test.file | zstd -c > test.tar.zst
Expand All @@ -29,8 +29,8 @@ jobs:
sudo mount -t tmpfs -o size=1100M tmpfs tmp
cp test.tar.zst tmp
cd tmp
cat-once --file test.tar.zst --chunk-size 55MB > test2.tar.zst
cat-once --file test2.tar.zst --chunk-size 42MB | tar -I zstd -xf - -C .
cat-once test.tar.zst --chunk-size 55MB > test2.tar.zst
cat-once test2.tar.zst --chunk-size 42MB | tar -I zstd -xf - -C .
sha1sum test.file > ../test-out.file.sha1
- name: Compare checksums
Expand All @@ -44,9 +44,9 @@ jobs:
for i in {1..100}; do
file_size=$(( ( RANDOM % 10000000 ) + 1 ))
chunk_size=$(( ( RANDOM % 1000000 ) + 20000 ))
cat-once --file test.file --test-create-ascii-file-size=$file_size
cat-once test.file --test-create-ascii-file-size=$file_size
sha1sum test.file > test-in.file.sha1
cargo run --release -- --file test.file --chunk-size $chunk_size > test-out.file
cargo run --release -- --chunk-size $chunk_size test.file > test-out.file
if [ -e "test.file" ]; then
echo "File exist but it should not"
exit 1
Expand Down
8 changes: 4 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ use std::env;
#[clap(author, version, about, long_about = None)]
struct Args {
/// Name of the file to read, warning it will be removed
#[clap(short, long)]
#[clap()]
file: String,

/// Percent of file at which truncate should be performed
#[clap(short, long)]
chunk_size: Option<bytesize::ByteSize>,

/// Dry run, do not perform any operations
/// Run otherwise simulate
#[clap(long)]
dry_run: bool,
run: bool,

#[clap(long)]
test_create_zero_file_size: Option<u64>,
Expand Down Expand Up @@ -99,7 +99,7 @@ fn main() -> anyhow::Result<()> {
args.chunk_size
.map(|v| v.as_u64())
.unwrap_or(default_chunk_size),
args.dry_run,
!args.run,
);
}
Ok(())
Expand Down

0 comments on commit 61e9780

Please sign in to comment.