|
| 1 | +use std::path::PathBuf; |
| 2 | +use structopt::StructOpt; |
| 3 | + |
| 4 | +/// A basic example |
| 5 | +#[derive(StructOpt, Debug)] |
| 6 | +#[structopt(name = "rust-pip", about = "Python package manager written in Rust.")] |
| 7 | +enum Opt { |
| 8 | + /// Install packages. |
| 9 | + Install {}, |
| 10 | + /// Download packages. |
| 11 | + Download { |
| 12 | + #[structopt(short = "n", long = "name")] |
| 13 | + name: String, |
| 14 | + #[structopt(short = "i", long = "index", default_value = "https://pypi.org/")] |
| 15 | + index: String, |
| 16 | + }, |
| 17 | + /// Uninstall packages. |
| 18 | + Uninstall {}, |
| 19 | + /// List installed packages. |
| 20 | + List {}, |
| 21 | + /// Show information about installed packages. |
| 22 | + Show {}, |
| 23 | + /// Output installed packages in requirements format. |
| 24 | + Freeze {}, |
| 25 | + /// Verify installed packages have compatible dependencies. |
| 26 | + Check {}, |
| 27 | + /// Manage local and global configuration. |
| 28 | + Config {}, |
| 29 | + /// Search PyPI for packages. |
| 30 | + Search {}, |
| 31 | + /// Inspect and manage pip's wheel cache. |
| 32 | + Cache {}, |
| 33 | + /// Inspect information available from package indexes. |
| 34 | + Index {}, |
| 35 | + /// Build wheels from your requirements. |
| 36 | + Wheel {}, |
| 37 | + /// Compute hashes of package archives. |
| 38 | + Hash {}, |
| 39 | + /// A helper command used for command completion. |
| 40 | + Completion {}, |
| 41 | + /// Show information useful for debugging. |
| 42 | + Debug {}, |
| 43 | + /// Show help for commands. |
| 44 | + Help {}, |
| 45 | +} |
| 46 | + |
| 47 | +fn download_package(package_name: String, package_index: &String) {} |
| 48 | + |
1 | 49 | fn main() {
|
2 |
| - println!("Hello, world!"); |
| 50 | + let opt = Opt::from_args(); |
| 51 | + println!("{:#?}", opt); |
| 52 | + |
| 53 | + match opt { |
| 54 | + Opt::Download { name, index } => { |
| 55 | + println!("Package name {:?}", name); |
| 56 | + println!("Index name: {:?}", index); |
| 57 | + download_package(name, &index); |
| 58 | + } |
| 59 | + _ => todo!(), |
| 60 | + } |
3 | 61 | }
|
0 commit comments