Skip to content

Commit

Permalink
Merge pull request #61 from simeg/editor-env-var
Browse files Browse the repository at this point in the history
Use $EDITOR to edit ideas, fall back to vim
  • Loading branch information
simeg authored Jun 9, 2020
2 parents 892fd48 + 9080322 commit 8d46b96
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 230 deletions.
156 changes: 8 additions & 148 deletions Cargo.lock

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

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,5 @@ exclude = [
[dependencies]
clap = "2.33.1"
dirs = "2.0.2"
dialoguer = "0.6.2"
termcolor = "1.1.0"
which = "4.0.0"
16 changes: 9 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ is the default structure when you create an empty repository with a readme on
GitHub, so it's easy to start using it. And since it's your own repository you
can make it private to keep your ideas secret.

`eureka` looks at your environment variables to decide what program to use.
* `$EDITOR` for what to edit your ideas with (falls back to `vim`)
* `$PAGER` for what to view your ideas with (falls back to `less`)

## Installation

**[Homebrew](https://brew.sh/)**
Expand All @@ -30,14 +34,13 @@ $ cargo install eureka
```

## Usage
The first time you run `eureka` it will ask a few questions regarding your
setup. This configuration will be stored in `~/.eureka/`.
The first time you run `eureka` it will ask for the path to your ideas repo.
This configuration will be stored in `~/.eureka/`.

After the setup simply run `eureka` to capture an idea. It will then be
committed and pushed to `origin/master`.

View your stored ideas in `$PAGER` env variable (falls back to `less`) with the
`-v` or `--view` flag.
View your stored ideas with the `-v` or `--view` flag.

```sh
$ eureka --view
Expand All @@ -46,9 +49,8 @@ $ eureka --view
### Flags

```sh
--clear-editor Clear the stored path to your idea editor
--clear-repo Clear the stored path to your idea repo
-v, --view View ideas with your $PAGER env variable. If unset use less
--clear-repo Clear the stored path to your idea repo
-v, --view View ideas with your $PAGER env variable. If unset use less
```

### Recommended alias
Expand Down
18 changes: 0 additions & 18 deletions src/bin/eureka.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ extern crate eureka;

#[macro_use]
extern crate clap;
extern crate dialoguer;
extern crate termcolor;

use std::io;
Expand All @@ -28,11 +27,6 @@ fn main() {
.long(ClearRepo.value())
.help("Clear the stored path to your idea repo"),
)
.arg(
Arg::with_name(ClearEditor.value())
.long(ClearEditor.value())
.help("Clear the stored path to your idea editor"),
)
.arg(
Arg::with_name(View.value())
.long(View.value())
Expand All @@ -51,20 +45,8 @@ fn main() {
printer: Printer { writer: output },
};

// Exit if any "clear" flag was provided
let mut should_exit = false;

if cli_flags.is_present(ClearRepo.value()) {
eureka.clear_repo();
should_exit = true;
}

if cli_flags.is_present(ClearEditor.value()) {
eureka.clear_editor();
should_exit = true;
}

if should_exit {
exit_w_code(0);
}

Expand Down
1 change: 0 additions & 1 deletion src/file_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ impl ConfigManagement for FileHandler {
fn config_path_for(config_type: ConfigFile) -> String {
let file_name = match config_type {
ConfigFile::Repo => ConfigFile::Repo.value(),
ConfigFile::Editor => ConfigFile::Editor.value(),
};

match home_dir() {
Expand Down
Loading

0 comments on commit 8d46b96

Please sign in to comment.