forge/cmd/soldeer.rs
1use clap::Parser;
2use eyre::Result;
3use foundry_common::shell;
4use soldeer_commands::{Command, Verbosity};
5// CLI arguments for `forge soldeer`.
6// The following list of commands and their actions:
7//
8// forge soldeer install: looks up the config file and install all the dependencies that are present
9// there forge soldeer install package~version: looks up on https://soldeer.xyz and if the package>version is there then add to config+lockfile and install new dependency. Replaces existing entry if version is different.
10// forge soldeer install package~version url: same behavior as install but instead of looking at https://soldeer.xyz it choses the URL, which can be git or custom zip url
11// forge soldeer update: same behavior as install looks up the config file and install all the
12// dependencies that are present there. This will change in the future forge soldeer login: logs in into https://soldeer.xyz account
13// forge soldeer push package~version: pushes files to the central repository
14// forge soldeer version: checks soldeer version
15// forge soldeer init: initializes a new project with minimal dependency for foundry setup, install
16// latest forge-std version forge soldeer uninstall dependency: uninstalls a dependency, removes
17// artifacts and configs
18
19#[derive(Clone, Debug, Parser)]
20#[command(
21 override_usage = "Native Solidity Package Manager, `run forge soldeer [COMMAND] --help` for more details"
22)]
23pub struct SoldeerArgs {
24 /// Command must be one of the following init/install/login/push/uninstall/update/version.
25 #[command(subcommand)]
26 command: Command,
27}
28
29impl SoldeerArgs {
30 pub async fn run(self) -> Result<()> {
31 let verbosity = Verbosity::new(shell::verbosity(), if shell::is_quiet() { 1 } else { 0 });
32 match soldeer_commands::run(self.command, verbosity).await {
33 Ok(_) => Ok(()),
34 Err(err) => Err(eyre::eyre!("Failed to run soldeer {}", err)),
35 }
36 }
37}
38
39#[cfg(test)]
40mod tests {
41 use soldeer_commands::{commands::Version, Command, Verbosity};
42
43 #[tokio::test]
44 async fn test_soldeer_version() {
45 let command = Command::Version(Version::default());
46 assert!(soldeer_commands::run(command, Verbosity::new(0, 1)).await.is_ok());
47 }
48}