Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

caps Download; thread-first aliases #259

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
101 changes: 45 additions & 56 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "calcit"
version = "0.9.7"
version = "0.9.8"
authors = ["jiyinyiyong <jiyinyiyong@gmail.com>"]
edition = "2021"
license = "MIT"
Expand All @@ -20,9 +20,9 @@ cirru_edn = "0.6.13"
cirru_parser = "0.1.31"
# cirru_parser = { path = "/Users/chenyong/repo/cirru/parser.rs" }
argh = "0.1.13"
dirs = "5.0.1"
notify = "7.0.0"
notify-debouncer-mini = "0.5.0"
dirs = "6.0.0"
notify = "8.0.0"
notify-debouncer-mini = "0.6.0"
walkdir = "2.5.0"
hex = "0.4.3"
rpds = "1.1.0"
Expand Down
12 changes: 12 additions & 0 deletions calcit/test-macro.cirru
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,10 @@
macroexpand $ quote
-> a (b c) (d e f)
quote $ d (b a c) e f
assert=
macroexpand $ quote
thread-first a (b c) (d e f)
quote $ -> a (b c) (d e f)
assert=
macroexpand-all $ quote
<- (b c) (d e f) a
Expand All @@ -260,6 +264,10 @@
macroexpand $ quote
->> a (b c) (d e f)
quote $ d e f (b c a)
assert=
macroexpand $ quote
thread-last a (b c) (d e f)
quote $ ->> a (b c) (d e f)
assert=
macroexpand $ quote (->% a)
quote a
Expand All @@ -270,6 +278,10 @@
% a
% $ + % 1
* % 2
assert=
macroexpand $ quote
thread-as a (+ % 1) (* % 2)
quote $ ->% a (+ % 1) (* % 2)
assert= 35 $ ->% 3 (+ % 4) (* % 5)
assert= 36 $ ->% 3 (+ % %) (* % %)
assert= 18 $ %<- (+ % %) (* % %) 3
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "@calcit/procs",
"version": "0.9.7",
"version": "0.9.8",
"main": "./lib/calcit.procs.mjs",
"devDependencies": {
"@types/node": "^22.10.5",
"typescript": "^5.7.2"
"@types/node": "^22.10.7",
"typescript": "^5.7.3"
},
"scripts": {
"compile": "rm -rfv lib/* && tsc",
Expand Down
40 changes: 36 additions & 4 deletions src/bin/calcit_deps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,22 @@ pub fn main() -> Result<(), String> {
// parse deps.cirru

let cli_args: TopLevelCaps = argh::from_env();
if let Some(SubCommand::Download(dep_names)) = &cli_args.subcommand {
if dep_names.packages.is_empty() {
eprintln!("Error: no packages to download!");
std::process::exit(1);
}
let dict: HashMap<Arc<str>, Arc<str>> = dep_names
.packages
.iter()
.map(|s| {
let (org_and_folder, version) = s.split_once('@').ok_or("invalid name")?;
Ok((org_and_folder.to_owned().into(), version.to_owned().into()))
})
.collect::<Result<_, String>>()?;
download_deps(dict, cli_args)?;
return Ok(());
}

// if file exists

Expand All @@ -75,10 +91,16 @@ pub fn main() -> Result<(), String> {
}
}

if cli_args.subcommand.is_some() {
outdated_tags(deps.dependencies)?;
} else {
download_deps(deps.dependencies, cli_args)?;
match &cli_args.subcommand {
Some(SubCommand::Outdated(_)) => {
outdated_tags(deps.dependencies)?;
}
Some(SubCommand::Download(dep_names)) => {
unreachable!("already handled: {:?}", dep_names);
}
None => {
download_deps(deps.dependencies, cli_args)?;
}
}

Ok(())
Expand Down Expand Up @@ -259,13 +281,23 @@ struct TopLevelCaps {
enum SubCommand {
/// show outdated versions
Outdated(OutdatedCaps),
Download(DownloadCaps),
}

#[derive(FromArgs, PartialEq, Debug, Clone)]
/// show outdated versions
#[argh(subcommand, name = "outdated")]
struct OutdatedCaps {}

#[derive(FromArgs, PartialEq, Debug, Clone)]
/// download named packages with org/repo@branch
#[argh(subcommand, name = "download")]
struct DownloadCaps {
/// packages to download, in format of `org/repo@branch`
#[argh(positional)]
packages: Vec<String>,
}

fn dim_println(msg: String) {
if msg.chars().nth(1) == Some(' ') {
println!("{}", msg.truecolor(128, 128, 128));
Expand Down
Loading
Loading