Skip to content

Commit

Permalink
refactor!: Rename --outfile to --out-file (#4679)
Browse files Browse the repository at this point in the history
Signed-off-by: Dmitry Murzin <[email protected]>
  • Loading branch information
dima74 authored Jun 3, 2024
1 parent 9c58203 commit f124f2e
Show file tree
Hide file tree
Showing 11 changed files with 26 additions and 26 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ It can be done by running:

```bash
# compile executor without optimizations
cargo run --bin iroha_wasm_builder -- build ./path/to/executor --outfile executor.wasm
cargo run --bin iroha_wasm_builder -- build ./path/to/executor --out-file executor.wasm
```

With profiling feature enabled Iroha exposes endpoint to scrap pprof profiles:
Expand Down
Binary file modified configs/swarm/executor.wasm
Binary file not shown.
2 changes: 1 addition & 1 deletion default_executor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ Use the [Wasm Builder CLI](../tools/wasm_builder_cli) in order to build it:

```bash
cargo run --bin iroha_wasm_builder -- \
build ./default_executor --optimize --outfile ./configs/swarm/executor.wasm
build ./default_executor --optimize --out-file ./configs/swarm/executor.wasm
```
8 changes: 4 additions & 4 deletions hooks/pre-commit.sample
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ cd ./client/tests/integration/smartcontracts
cargo fmt --all -- --check
cd -
# update the default executor
cargo run --release --bin iroha_wasm_builder -- build ./default_executor --optimize --outfile ./configs/swarm/executor.wasm
cargo run --release --bin iroha_wasm_builder -- build ./default_executor --optimize --out-file ./configs/swarm/executor.wasm
# update the default genesis, assuming the transaction authority is `test_samples::SAMPLE_GENESIS_ACCOUNT_ID`
cargo run --release --bin kagami -- genesis --executor-path-in-genesis ./executor.wasm --genesis-public-key ed01204164BF554923ECE1FD412D241036D863A6AE430476C898248B8237D77534CFC4 > ./configs/swarm/genesis.json
# update schema
cargo run --release --bin kagami -- schema > ./docs/source/references/schema.json
# update docker compose files
cargo run --release --bin iroha_swarm -- -p 1 -s Iroha --force --config-dir ./configs/swarm --health-check --build . --outfile ./configs/swarm/docker-compose.single.yml
cargo run --release --bin iroha_swarm -- -p 4 -s Iroha --force --config-dir ./configs/swarm --health-check --build . --outfile ./configs/swarm/docker-compose.local.yml
cargo run --release --bin iroha_swarm -- -p 4 -s Iroha --force --config-dir ./configs/swarm --health-check --image hyperledger/iroha2:dev --outfile ./configs/swarm/docker-compose.yml
cargo run --release --bin iroha_swarm -- -p 1 -s Iroha --force --config-dir ./configs/swarm --health-check --build . --out-file ./configs/swarm/docker-compose.single.yml
cargo run --release --bin iroha_swarm -- -p 4 -s Iroha --force --config-dir ./configs/swarm --health-check --build . --out-file ./configs/swarm/docker-compose.local.yml
cargo run --release --bin iroha_swarm -- -p 4 -s Iroha --force --config-dir ./configs/swarm --health-check --image hyperledger/iroha2:dev --out-file ./configs/swarm/docker-compose.yml
# lints
cargo lints clippy --workspace --benches --tests --examples --all-features
# stage updates
Expand Down
2 changes: 1 addition & 1 deletion scripts/generate_wasm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ for folder in "$SOURCE_DIR"/*; do
folder_name=$(basename "$folder")
target_wasm_file_path="${TARGET_DIR}/${folder_name}.wasm"
# Build the smart contracts
cargo run --bin iroha_wasm_builder -- build "$folder" --optimize --outfile "$target_wasm_file_path"
cargo run --bin iroha_wasm_builder -- build "$folder" --optimize --out-file "$target_wasm_file_path"

fi
done
Expand Down
4 changes: 2 additions & 2 deletions scripts/tests/consistency.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ case $1 in
# it is not a default behaviour because Kagami resolves `build` path relative
# to the output file location
temp_file="configs/swarm/docker-compose.TMP.yml"
full_cmd="$cmd_base --outfile $temp_file"
full_cmd="$cmd_base --out-file $temp_file"

eval "$full_cmd"
diff "$temp_file" "$target" || {
echo "Please re-generate \`$target\` with \`$cmd_base --outfile $target\`"
echo "Please re-generate \`$target\` with \`$cmd_base --out-file $target\`"
exit 1
}
}
Expand Down
10 changes: 5 additions & 5 deletions tools/swarm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ iroha_swarm <options>

**Options:**

- **`--outfile <path>`** (required): specify the output file name, e.g. `./docker-compose.yml`. If the file exists, the prompt appears (might be disabled with `--force` option).
- **`--config-dir <path>`** (required): specify the path to the directory containing `config.json` and `genesis.json`. The path to the config will be written into the file specified by `--outfile` relative to its location.
- **`--out-file <path>`** (required): specify the output file name, e.g. `./docker-compose.yml`. If the file exists, the prompt appears (might be disabled with `--force` option).
- **`--config-dir <path>`** (required): specify the path to the directory containing `config.json` and `genesis.json`. The path to the config will be written into the file specified by `--out-file` relative to its location.
- **Image source** (required):
- **`--image <name>`**: specify image name, like `hyperledger/iroha2:dev`
- **`--build <path>`**: specify path to the Iroha repo
- **`--peers <number>` (`-p`)** (required): amount of peers to generate
- **`--seed <string>` (`-s`)** (optional): specify a string to use as a cryptographic seed for keys generation. Allows to generate compose configurations deterministically. UTF-8 bytes of the string will be used.
- **`--force`** (optional): override file specified with `--outfile` if it exists
- **`--force`** (optional): override file specified with `--out-file` if it exists

## Examples

Expand All @@ -29,7 +29,7 @@ iroha_swarm \
--peers 5 \
--seed iroha \
--config-dir ./peer_config \
--outfile docker-compose.dev.yml
--out-file docker-compose.dev.yml
```

Same, but using an existing Docker image instead:
Expand All @@ -40,5 +40,5 @@ iroha_swarm \
--peers 5 \
--seed iroha \
--config-dir ./peer_config \
--outfile docker-compose.dev.yml
--out-file docker-compose.dev.yml
```
8 changes: 4 additions & 4 deletions tools/swarm/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub struct Cli {
/// interactive, the app will stop execution with a non-zero exit code. In order to
/// overwrite the file anyway, pass `--force` flag.
#[arg(long, short)]
pub outfile: PathBuf,
pub out_file: PathBuf,
/// Disable banner in the file saying that the file is generated.
///
/// It includes all passed arguments in order to help with reproducibility.
Expand Down Expand Up @@ -115,17 +115,17 @@ mod tests {

#[test]
fn work_with_build_source() {
let _ = match_args("-p 20 --build . --config-dir ./config --outfile sample.yml").unwrap();
let _ = match_args("-p 20 --build . --config-dir ./config --out-file sample.yml").unwrap();
}

#[test]
fn doesnt_allow_multiple_sources() {
let _ = match_args("-p 1 --build . --image hp/irohad --config-dir ./ --outfile test.yml")
let _ = match_args("-p 1 --build . --image hp/irohad --config-dir ./ --out-file test.yml")
.unwrap_err();
}

#[test]
fn doesnt_allow_omitting_source() {
let _ = match_args("-p 1 --outfile test.yml --config-dir ./").unwrap_err();
let _ = match_args("-p 1 --out-file test.yml --config-dir ./").unwrap_err();
}
}
2 changes: 1 addition & 1 deletion tools/swarm/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ fn main() -> Result<()> {
force,
no_banner,
source: image_source,
outfile: target_file_raw,
out_file: target_file_raw,
config_dir: config_dir_raw,
health_check,
} = Cli::parse();
Expand Down
4 changes: 2 additions & 2 deletions tools/wasm_builder_cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ iroha_wasm_builder check path/to/project
**Build the smartcontract:**

```bash
iroha_wasm_builder build path/to/project --outfile ./smartcontract.wasm
iroha_wasm_builder build path/to/project --out-file ./smartcontract.wasm
```

**Build with options:**

```bash
iroha_wasm_builder build path/to/project --optimize --format --outfile ./smartcontract.wasm
iroha_wasm_builder build path/to/project --optimize --format --out-file ./smartcontract.wasm
```
10 changes: 5 additions & 5 deletions tools/wasm_builder_cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ enum Cli {
optimize: bool,
/// Where to store the output WASM. If the file exists, it will be overwritten.
#[arg(long)]
outfile: PathBuf,
out_file: PathBuf,
},
}

Expand All @@ -45,7 +45,7 @@ fn main() -> color_eyre::Result<()> {
Cli::Build {
common: CommonArgs { path },
optimize,
outfile,
out_file,
} => {
let builder = Builder::new(&path).show_output();

Expand Down Expand Up @@ -80,16 +80,16 @@ fn main() -> color_eyre::Result<()> {
output
};

std::fs::copy(output.wasm_file_path(), &outfile).wrap_err_with(|| {
std::fs::copy(output.wasm_file_path(), &out_file).wrap_err_with(|| {
eyre!(
"Failed to write the resulting file into {}",
outfile.display()
out_file.display()
)
})?;

println!(
"✓ File is written into {}",
outfile.display().green().bold()
out_file.display().green().bold()
);
}
}
Expand Down

0 comments on commit f124f2e

Please sign in to comment.