diff --git a/.github/workflows/cd.yml b/.github/workflows/release.yml similarity index 86% rename from .github/workflows/cd.yml rename to .github/workflows/release.yml index ecd8833b..3a4c811f 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/release.yml @@ -1,4 +1,4 @@ -name: Continuous Deployment +name: Release on: push: @@ -15,15 +15,15 @@ jobs: rust: [stable] include: - os: macos-latest - artifact_prefix: macos + artifact_prefix: darwin-amd64 target: x86_64-apple-darwin binary_postfix: "" - os: ubuntu-latest - artifact_prefix: linux + artifact_prefix: linux-amd64 target: x86_64-unknown-linux-gnu binary_postfix: "" - os: windows-latest - artifact_prefix: windows + artifact_prefix: windows-amd64 target: x86_64-pc-windows-msvc binary_postfix: ".exe" @@ -48,14 +48,14 @@ jobs: with: command: build toolchain: ${{ matrix.rust }} - args: --release --features="bin" --target ${{ matrix.target }} + args: --release --features bin --target ${{ matrix.target }} - name: Packaging final binary shell: bash run: | cd target/${{ matrix.target }}/release - BINARY_NAME=autocorrect - RELEASE_NAME=autocorrect + BINARY_NAME=autocorrect${{ matrix.binary_postfix }} + RELEASE_NAME=autocorrect-${{ matrix.artifact_prefix }} tar czvf $RELEASE_NAME.tar.gz $BINARY_NAME if [[ ${{ runner.os }} == 'Windows' ]]; then certutil -hashfile $RELEASE_NAME.tar.gz sha256 | grep -E [A-Fa-f0-9]{64} > $RELEASE_NAME.sha256 diff --git a/Cargo.toml b/Cargo.toml index e4206479..1b8e47b3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,7 +8,7 @@ license = "MIT" name = "autocorrect" readme = "README.md" repository = "https://github.com/huacnlee/auto-correct.rs" -version = "0.4.4-alpha.0" +version = "0.4.3" [lib] name = "autocorrect" diff --git a/Makefile b/Makefile index 0757eb34..3a75a250 100644 --- a/Makefile +++ b/Makefile @@ -4,3 +4,8 @@ release: cargo release --features="bin" run: cargo run --features="bin" +release\:bin: + cargo +stable build --release --features bin --target aarch64-apple-darwin + cd target/aarch64-apple-darwin/release + tar czvf autocorrect-aarch64-apple-darwin.tar.gz autocorrect + mv autocorrect-aarch64-apple-darwin.tar.gz ~/Downloads/ \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index ed790fa0..c0166d2f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,12 +1,13 @@ use autocorrect::{format, format_html}; -use clap::{App, Arg, SubCommand}; +use clap::{crate_version, App, Arg, SubCommand}; use glob::glob; use std::fs; +use std::path::Path; pub fn main() { let matches = App::new("AutoCorrect") .author("Jason Lee path = String::from(_path.to_str().unwrap()), - Err(_e) => break, + let path_exist = Path::new(file_name).exists(); + if path_exist { + for f in glob(file_name).unwrap() { + let path: String; + match f { + Ok(_path) => path = String::from(_path.to_str().unwrap()), + Err(_e) => break, + } + let raw = fs::read_to_string(path).unwrap(); + let raw = raw.as_str(); + if matches.is_present("html") { + println!("{}", format(raw)); + } else { + println!("{}", format_html(raw)); + } } - - let raw = fs::read_to_string(path).unwrap(); - let raw = raw.as_str(); - + } else { + let raw = file_name; if matches.is_present("html") { println!("{}", format(raw)); } else {