-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
breaking refactor with argh; tag 0.9.0-a1
- Loading branch information
Showing
11 changed files
with
206 additions
and
364 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,3 +19,5 @@ builds/ | |
.DS_Store | ||
|
||
/profile.json | ||
|
||
.DS_Store |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "calcit" | ||
version = "0.8.59" | ||
version = "0.9.0-a1" | ||
authors = ["jiyinyiyong <[email protected]>"] | ||
edition = "2021" | ||
license = "MIT" | ||
|
@@ -24,7 +24,7 @@ cirru_edn = "0.6.11" | |
# cirru_edn = { path = "/Users/chenyong/repo/cirru/edn.rs" } | ||
cirru_parser = "0.1.31" | ||
# cirru_parser = { path = "/Users/chenyong/repo/cirru/parser.rs" } | ||
clap = "4.5.7" | ||
argh = "0.1.12" | ||
dirs = "5.0.1" | ||
lazy_static = "1.4.0" | ||
notify = "6.1.1" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "@calcit/procs", | ||
"version": "0.8.59", | ||
"version": "0.9.0-a1", | ||
"main": "./lib/calcit.procs.mjs", | ||
"devDependencies": { | ||
"@types/node": "^20.11.28", | ||
|
@@ -10,12 +10,12 @@ | |
"compile": "rm -rfv lib/* && tsc", | ||
"procs-link": "ln -s ../../ node_modules/@calcit/procs", | ||
"cp-mac": "cargo build --release && rm -rfv builds/* && node scripts/cp-version.js && scp builds/* [email protected]:/web-assets/repo/calcit-lang/binaries/macos/", | ||
"eval": "cargo run --bin cr -- -e", | ||
"eval": "cargo run --bin cr -- eval", | ||
"check-all": "yarn compile && yarn try-rs && yarn try-js && yarn try-ir", | ||
"try-rs": "cargo run --bin cr -- calcit/test.cirru -1", | ||
"try-js-brk": "cargo run --bin cr -- calcit/test.cirru --emit-js -1 && node --inspect-brk js-out/main.mjs", | ||
"try-js": "cargo run --bin cr -- calcit/test.cirru --emit-js -1 && node js-out/main.mjs", | ||
"try-ir": "cargo run --bin cr -- calcit/test.cirru --emit-ir -1" | ||
"try-js-brk": "cargo run --bin cr -- calcit/test.cirru -1 js && node --inspect-brk js-out/main.mjs", | ||
"try-js": "cargo run --bin cr -- calcit/test.cirru -1 js && node js-out/main.mjs", | ||
"try-ir": "cargo run --bin cr -- calcit/test.cirru -1 js" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,8 @@ use std::{ | |
sync::Arc, | ||
}; | ||
|
||
use argh::FromArgs; | ||
|
||
use calcit::snapshot::{ChangesDict, CodeEntry}; | ||
use calcit::snapshot::{FileChangeInfo, FileInSnapShot}; | ||
|
||
|
@@ -22,10 +24,13 @@ use cirru_edn::{Edn, EdnMapView, EdnRecordView, EdnTag}; | |
use cirru_parser::Cirru; | ||
|
||
pub fn main() -> io::Result<()> { | ||
let cli_matches = parse_cli(); | ||
let verbose = cli_matches.get_flag("verbose"); | ||
let base_dir = Path::new(cli_matches.get_one::<String>("src").expect("src")); | ||
let out_path = Path::new(cli_matches.get_one::<String>("out").expect("out")); | ||
let cli_args: TopLevelBundleCalcit = argh::from_env(); | ||
|
||
let verbose = cli_args.verbose; | ||
let src = cli_args.src.as_deref().unwrap_or("src"); | ||
let base_dir = Path::new(&src); | ||
let out = cli_args.out.as_deref().unwrap_or("./"); | ||
let out_path = Path::new(&out); | ||
let out_file = match out_path.extension() { | ||
Some(ext) => { | ||
let ext_str = ext.to_str().expect("ext"); | ||
|
@@ -38,12 +43,9 @@ pub fn main() -> io::Result<()> { | |
None => out_path.join("compact.cirru"), | ||
}; | ||
let inc_file_path = out_path.join(".compact-inc.cirru"); | ||
let no_watcher = cli_matches.get_flag("once"); | ||
let no_watcher = cli_args.once; | ||
|
||
let package_file = Path::new(cli_matches.get_one::<String>("src").expect("src")) | ||
.parent() | ||
.expect("parent path") | ||
.join("package.cirru"); | ||
let package_file = base_dir.parent().expect("parent path").join("package.cirru"); | ||
|
||
perform_compaction(base_dir, &package_file, &out_file, &inc_file_path, verbose)?; | ||
|
||
|
@@ -272,42 +274,21 @@ fn load_files_to_edn(package_file: &Path, base_dir: &Path, verbose: bool) -> Res | |
|
||
pub const CALCIT_VERSION: &str = env!("CARGO_PKG_VERSION"); | ||
|
||
fn parse_cli() -> clap::ArgMatches { | ||
clap::Command::new("Calcit Bundle") | ||
.version(CALCIT_VERSION) | ||
.author("Jon. <[email protected]>") | ||
.about("Calcit Bundler") | ||
.arg( | ||
clap::Arg::new("src") | ||
.help("source folder") | ||
.default_value("src/") | ||
.short('s') | ||
.long("src") | ||
.num_args(1), | ||
) | ||
.arg( | ||
clap::Arg::new("out") | ||
.help("output folder") | ||
.default_value("./") // TODO a better default value | ||
.short('o') | ||
.long("out") | ||
.num_args(1), | ||
) | ||
.arg( | ||
clap::Arg::new("verbose") | ||
.help("verbose mode") | ||
.short('v') | ||
.long("verbose") | ||
.num_args(0), | ||
) | ||
.arg( | ||
clap::Arg::new("once") | ||
.help("run without watcher") | ||
.short('1') | ||
.long("once") | ||
.num_args(0), | ||
) | ||
.get_matches() | ||
#[derive(FromArgs, PartialEq, Debug)] | ||
/// Top-level command. | ||
pub struct TopLevelBundleCalcit { | ||
/// source folder | ||
#[argh(option, short = 's')] | ||
pub src: Option<String>, | ||
/// output folder | ||
#[argh(option, short = 'o')] | ||
pub out: Option<String>, | ||
/// verbose mode | ||
#[argh(switch, short = 'v')] | ||
pub verbose: bool, | ||
/// run without watcher | ||
#[argh(switch, short = '1')] | ||
pub once: bool, | ||
} | ||
|
||
// simulate an IO error with String | ||
|
Oops, something went wrong.