Skip to content

Commit

Permalink
Merge pull request #3 from lukaszKielar/cli
Browse files Browse the repository at this point in the history
Add CLI commands
  • Loading branch information
lukaszKielar authored Oct 11, 2020
2 parents 2231b7b + 1773c53 commit 214a1c9
Show file tree
Hide file tree
Showing 8 changed files with 200 additions and 84 deletions.
1 change: 0 additions & 1 deletion .env

This file was deleted.

80 changes: 71 additions & 9 deletions Cargo.lock

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

9 changes: 6 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
[package]
name = "conda-leaves"
version = "0.0.1"
version = "0.1.0"
authors = ["lukaszKielar <[email protected]>"]
edition = "2018"
license-file = "LICENSE"
descrption = "Simple CLI tool that allows to pretty print all dependencies within conda environment"
repository = "https://github.com/lukaszKielar/conda-leaves"
readme = "README.md"

[dependencies]
colored = "2"
clap = "2.33"
dotenv = "0.15.0"
env_logger = "0.7.1"
glob = "0.3.0"
lazy_static = "1.4.0"
log = "0.4"
regex = "1.3.9"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
structopt = "0.3"
62 changes: 60 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,70 @@

Simple CLI tool that allows to pretty print all dependencies within conda environment.

## Installation

`conda-leaves` doesn't require any additional libraries to be installed, but it assumes user has `conda` and `cargo` installed and available in system's path.

Installation is as simple as running `cargo install conda-leaves`.

## Commands

### `help`

Prints help information.

```bash
conda-leaves help
```

### `leaves`

Prints top level packages in conda environment.

Flags:

- `--no-pip` - Prints packages installed by conda only

Usage:

```bash
conda-leaves leaves [Flags]
```

### `package`

Prints tree view for the package.

Options:

- `-n`, `-name` - Name of the package that should be printed.

Usage:

```bash
conda-leaves package --name <name>
```

### `export`

Exports leaves to the file.

Options:

- `-f`, `--filename` (default: environment.yml) - Name of the output yml file.

Usage:

```bash
conda-leaves export [Options]
```

## Development

### Running main using test data
### Running CLI using test data

```bash
CONDA_PREFIX="./tests/data" cargo run --release
CONDA_PREFIX="./tests/data" cargo run --release -- <command>
```

### Running tests
Expand Down
3 changes: 0 additions & 3 deletions environment.yml

This file was deleted.

34 changes: 0 additions & 34 deletions src/cli.rs

This file was deleted.

8 changes: 6 additions & 2 deletions src/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use std::env;
use std::fs;
use std::io;
use std::io::prelude::*;
use std::path::Path;

use crate::metadata::Metadata;
use crate::package::{Installer, Package};
Expand All @@ -15,10 +16,13 @@ pub struct CondaEnv {

impl CondaEnv {
// TODO add information about version
pub fn to_yml(&self) -> io::Result<()> {
pub fn to_yml<'a, P>(&self, filename: &'a P) -> io::Result<()>
where
P: 'a + ?Sized + AsRef<Path>,
{
// create a file in current directory
// TODO path could be passed as an argument
let path = env::current_dir()?.join("environment2.yml");
let path = env::current_dir()?.join(filename);
let mut file = fs::File::create(path)?;

// write name to the file
Expand Down
Loading

0 comments on commit 214a1c9

Please sign in to comment.