-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #490 from moonbitlang/install_bin
feat: support moon install --bin
- Loading branch information
Showing
68 changed files
with
902 additions
and
81 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
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 |
---|---|---|
|
@@ -17,42 +17,29 @@ | |
// For inquiries, you can contact us via e-mail at [email protected]. | ||
|
||
use anyhow::bail; | ||
use mooncake::pkg::{ | ||
add::AddSubcommand, install::InstallSubcommand, remove::RemoveSubcommand, tree::TreeSubcommand, | ||
}; | ||
use moonutil::{ | ||
dirs::PackageDirs, | ||
mooncakes::{ModuleName, RegistryConfig}, | ||
}; | ||
|
||
use super::UniversalFlags; | ||
|
||
/// Install dependencies | ||
#[derive(Debug, clap::Parser)] | ||
pub struct InstallSubcommand {} | ||
|
||
/// Remove a dependency | ||
#[derive(Debug, clap::Parser)] | ||
pub struct RemoveSubcommand { | ||
/// The package path to remove | ||
pub package_path: String, | ||
} | ||
|
||
/// Add a dependency | ||
#[derive(Debug, clap::Parser)] | ||
pub struct AddSubcommand { | ||
/// The package path to add | ||
pub package_path: String, | ||
} | ||
|
||
/// Display the dependency tree | ||
#[derive(Debug, clap::Parser)] | ||
pub struct TreeSubcommand {} | ||
|
||
pub fn install_cli(cli: UniversalFlags, _cmd: InstallSubcommand) -> anyhow::Result<i32> { | ||
let PackageDirs { | ||
source_dir, | ||
target_dir, | ||
} = cli.source_tgt_dir.try_into_package_dirs()?; | ||
let registry_config = RegistryConfig::load(); | ||
mooncake::pkg::install::install(&source_dir, &target_dir, ®istry_config, false) | ||
mooncake::pkg::install::install( | ||
&source_dir, | ||
&target_dir, | ||
®istry_config, | ||
cli.quiet, | ||
cli.verbose, | ||
) | ||
} | ||
|
||
pub fn remove_cli(cli: UniversalFlags, cmd: RemoveSubcommand) -> anyhow::Result<i32> { | ||
|
@@ -100,9 +87,16 @@ pub fn add_cli(cli: UniversalFlags, cmd: AddSubcommand) -> anyhow::Result<i32> { | |
if parts.len() == 2 { | ||
let version: &str = parts[1]; | ||
let version = version.parse()?; | ||
mooncake::pkg::add::add(&source_dir, &target_dir, &pkg_name, &version, false) | ||
mooncake::pkg::add::add( | ||
&source_dir, | ||
&target_dir, | ||
&pkg_name, | ||
cmd.bin, | ||
&version, | ||
false, | ||
) | ||
} else { | ||
mooncake::pkg::add::add_latest(&source_dir, &target_dir, &pkg_name, false) | ||
mooncake::pkg::add::add_latest(&source_dir, &target_dir, &pkg_name, cmd.bin, false) | ||
} | ||
} | ||
|
||
|
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
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
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
2 changes: 2 additions & 0 deletions
2
crates/moon/tests/test_cases/moon_install_bin.in/author1.in/.gitignore
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
target/ | ||
.mooncakes/ |
1 change: 1 addition & 0 deletions
1
crates/moon/tests/test_cases/moon_install_bin.in/author1.in/README.md
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
# username/hello |
3 changes: 3 additions & 0 deletions
3
crates/moon/tests/test_cases/moon_install_bin.in/author1.in/lib/hello.mbt
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
pub fn hello() -> Unit { | ||
println("lib Hello, world!") | ||
} |
3 changes: 3 additions & 0 deletions
3
crates/moon/tests/test_cases/moon_install_bin.in/author1.in/lib/moon.pkg.json
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
|
||
} |
4 changes: 4 additions & 0 deletions
4
crates/moon/tests/test_cases/moon_install_bin.in/author1.in/main-js/main.mbt
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
fn main { | ||
println("main-js") | ||
println(@lib.hello()) | ||
} |
7 changes: 7 additions & 0 deletions
7
crates/moon/tests/test_cases/moon_install_bin.in/author1.in/main-js/moon.pkg.json
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"is_main": true, | ||
"import": [ | ||
"username/flash/lib" | ||
], | ||
"bin-target": "js" | ||
} |
4 changes: 4 additions & 0 deletions
4
crates/moon/tests/test_cases/moon_install_bin.in/author1.in/main-native/main.mbt
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
fn main { | ||
println("main-native") | ||
println(@lib.hello()) | ||
} |
8 changes: 8 additions & 0 deletions
8
crates/moon/tests/test_cases/moon_install_bin.in/author1.in/main-native/moon.pkg.json
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"is_main": true, | ||
"import": [ | ||
"username/flash/lib" | ||
], | ||
"bin-target": "native", | ||
"bin-name": "this-is-native" | ||
} |
4 changes: 4 additions & 0 deletions
4
crates/moon/tests/test_cases/moon_install_bin.in/author1.in/main-wasm/main.mbt
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
fn main { | ||
println("main-wasm") | ||
println(@lib.hello()) | ||
} |
8 changes: 8 additions & 0 deletions
8
crates/moon/tests/test_cases/moon_install_bin.in/author1.in/main-wasm/moon.pkg.json
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"is_main": true, | ||
"import": [ | ||
"username/flash/lib" | ||
], | ||
"bin-target": "wasm", | ||
"bin-name": "this-is-wasm" | ||
} |
9 changes: 9 additions & 0 deletions
9
crates/moon/tests/test_cases/moon_install_bin.in/author1.in/moon.mod.json
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"name": "username/flash", | ||
"version": "0.1.0", | ||
"readme": "README.md", | ||
"repository": "", | ||
"license": "Apache-2.0", | ||
"keywords": [], | ||
"description": "" | ||
} |
2 changes: 2 additions & 0 deletions
2
crates/moon/tests/test_cases/moon_install_bin.in/author2.in/.gitignore
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
target/ | ||
.mooncakes/ |
1 change: 1 addition & 0 deletions
1
crates/moon/tests/test_cases/moon_install_bin.in/author2.in/README.md
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
# username/hello |
3 changes: 3 additions & 0 deletions
3
crates/moon/tests/test_cases/moon_install_bin.in/author2.in/lib/hello.mbt
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
pub fn hello() -> Unit { | ||
println("lib Hello, world!") | ||
} |
3 changes: 3 additions & 0 deletions
3
crates/moon/tests/test_cases/moon_install_bin.in/author2.in/lib/moon.pkg.json
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
|
||
} |
4 changes: 4 additions & 0 deletions
4
crates/moon/tests/test_cases/moon_install_bin.in/author2.in/main-js/main.mbt
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
fn main { | ||
println("main-js") | ||
println(@lib.hello()) | ||
} |
8 changes: 8 additions & 0 deletions
8
crates/moon/tests/test_cases/moon_install_bin.in/author2.in/main-js/moon.pkg.json
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"is_main": true, | ||
"import": [ | ||
"author2/flash/lib" | ||
], | ||
"bin-target": "js", | ||
"bin-name": "author2-js" | ||
} |
4 changes: 4 additions & 0 deletions
4
crates/moon/tests/test_cases/moon_install_bin.in/author2.in/main-native/main.mbt
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
fn main { | ||
println("main-native") | ||
println(@lib.hello()) | ||
} |
8 changes: 8 additions & 0 deletions
8
crates/moon/tests/test_cases/moon_install_bin.in/author2.in/main-native/moon.pkg.json
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"is_main": true, | ||
"import": [ | ||
"author2/flash/lib" | ||
], | ||
"bin-target": "native", | ||
"bin-name": "author2-native" | ||
} |
4 changes: 4 additions & 0 deletions
4
crates/moon/tests/test_cases/moon_install_bin.in/author2.in/main-wasm/main.mbt
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
fn main { | ||
println("main-wasm") | ||
println(@lib.hello()) | ||
} |
8 changes: 8 additions & 0 deletions
8
crates/moon/tests/test_cases/moon_install_bin.in/author2.in/main-wasm/moon.pkg.json
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"is_main": true, | ||
"import": [ | ||
"author2/flash/lib" | ||
], | ||
"bin-target": "wasm", | ||
"bin-name": "author2-wasm" | ||
} |
9 changes: 9 additions & 0 deletions
9
crates/moon/tests/test_cases/moon_install_bin.in/author2.in/moon.mod.json
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"name": "author2/flash", | ||
"version": "0.1.0", | ||
"readme": "README.md", | ||
"repository": "", | ||
"license": "Apache-2.0", | ||
"keywords": [], | ||
"description": "" | ||
} |
Oops, something went wrong.