Skip to content

Commit

Permalink
adding some short options and clarifying readme
Browse files Browse the repository at this point in the history
  • Loading branch information
machellerogden committed Feb 15, 2017
1 parent e9a68da commit e8f2f24
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 21 deletions.
39 changes: 26 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,44 +9,57 @@

_zsh support coming soon..._

## Installation & Setup
## Installation

```
npm i -g bitcar
```

## Setup

```
bitcar --setup
```

Setup will drop a few dotfiles in `~/.bitcar` and it will append a few lines to your `~/.bash_profile`.

Note: You MUST use the command name you chose during setup. Only use the `bitcar` command itself for setup.

**IMPORTANT: Now, start a new terminal session.**

## Usage

### Initialize Cache
In the examples below, it is assumed you have set your bitcar command to `bit`. If you've chosen a different command name, adjust accordingly.

### Search / Clone / Change Directory to Repo

```
bitcar --init
bit {searchTerm}
```

This is done automatically the first time you try and use bitcar, but you can also invoke it manually with the above command.
### Open Repo in Browser

### Refresh Cache
```
bit --open {searchTerm}
```

```
bitcar --refresh
bit -o {searchTerm}
```

### Search / Clone / Change Directory to Repo
The `searchTerm` argument is optional. If no `searchTerm` is given, then bitcar will attempt to open the current directory's repo in the browser.

### Refresh Cache

```
bit {searchTerm}
bit --refresh
```

### Open Repo in Browser

```
bit --open {searchTerm}
bit -r
```

The `searchTerm` argument is optional. If no `searchTerm` is given, then bitcar will attempt to open the current directory's repo in the browser.
This is done automatically the first time you try and use bitcar, but you can also manual refresh the cache when needed.

## Github personal access token settings

Expand All @@ -55,6 +68,6 @@ If you'd like to use bitcar with your private repos, you'll need to setup a
account](https://github.com/settings/tokens/new). Please ensure you've set the
correct scope for this token. The `repo` scope should be fully enabled.

## license
## License

Apache 2.0
8 changes: 8 additions & 0 deletions argv.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
'use strict';
module.exports = require('minimist')(process.argv.slice(2), {
alias: {
version: 'v',
open: 'o',
refresh: 'r'
}
});
7 changes: 2 additions & 5 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@ const inquirer = require('inquirer');
const path = require('path');

const refresh = _.partial(lib.getSourceData, true);
const init = refresh;

module.exports = cli;

function cli(options) {
let searchTerm;

if (options.version || options.v) {
if (options.version) {
console.log(require('./package.json').version);
process.exit(0);
}
Expand All @@ -31,9 +30,7 @@ function cli(options) {
searchTerm = '^' + _.takeRight(process.cwd().split(path.sep), 3).join(path.sep) + '$';
}

if (options.init) {
return init();
} else if (options.refresh) {
if (options.refresh) {
return refresh();
} else {
const searchFilter = (v) => (new RegExp(searchTerm)).test(v);
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env node
const cli = require('./cli');
const argv = require('optimist').argv;
const argv = require('./argv');
const setTarget = require('./lib/setTarget');

cli(argv)
Expand Down
1 change: 0 additions & 1 deletion lib/getSourceData.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
'use strict';

const fs = require('./fs');
const path = require('path');
const _ = require('lodash');
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@
"lodash": "^4.17.4",
"mem-fs": "^1.1.3",
"mem-fs-editor": "^3.0.2",
"minimist": "^1.2.0",
"mkdirp": "^0.5.1",
"omelette": "^0.3.1",
"open": "0.0.5",
"optimist": "^0.6.1",
"rc": "^1.1.6",
"simple-git": "^1.65.0"
},
Expand Down

0 comments on commit e8f2f24

Please sign in to comment.