Skip to content

Commit f7411ab

Browse files
committed
docs: create cli.md and cli.md
1 parent 16e202a commit f7411ab

File tree

2 files changed

+112
-0
lines changed

2 files changed

+112
-0
lines changed

docs/cli.md

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
# CLI
2+
> How to use AutoCommitMsg in the terminal instead of as an extension
3+
4+
See steps below to setup and run the tool in the CLI. VS Code is not needed.
5+
6+
For development, see [CLI Development](development/cli.md).
7+
8+
## Requirements
9+
10+
- Node (see version in [package.json](/package.json))
11+
- Git
12+
13+
_This should work on Windows too but has not been tested yet._
14+
15+
## Setup
16+
17+
### Clone the repo
18+
19+
```sh
20+
$ git clone [email protected]:MichaelCurrin/auto-commit-msg.git
21+
$ cd auto-commit-msg
22+
```
23+
24+
### Install dependencies
25+
26+
```sh
27+
$ npm ci
28+
```
29+
30+
### Build and link the CLI tools
31+
32+
```sh
33+
$ npm run cli:install
34+
```
35+
36+
Verify installation:
37+
38+
```sh
39+
$ acm -h
40+
$ gacm -h
41+
```
42+
43+
## Usage
44+
45+
Use the `-h` or `--help` flags with any of these to avoid making changes.
46+
47+
<!--
48+
TODO consolidate to one command with commit flag?
49+
TODO pass params like file names through for either command. For message and committing. The downside is for new files - even if git commit would pick them up by name, diff-index would not. You can also use whatever IDE to stage and still generate+commit with the CLI.
50+
TODO -c not just --cached
51+
-->
52+
53+
### Generate a message from changes and commit
54+
55+
This is the **main** command you should use.
56+
57+
Note this actually **commit**, so if you want to experiment with commit output **without** committing, use the command below instead.
58+
59+
No flags are needed.
60+
61+
```sh
62+
$ gacm
63+
```
64+
65+
### Check Git changes and generate commit message
66+
67+
This will **not** commit.
68+
69+
No flags are needed.
70+
71+
```sh
72+
$ acm
73+
```
74+
75+
### Generate a message from staged changes
76+
77+
This is a simpler command which does not interact with Git, intended for integrating with the Bash shell.
78+
79+
See [shell/acm.sh](/shell/acm.sh) if you want to use that script or write your own shell script. That relies on using this executable Node script
80+
81+
```sh
82+
$ auto_commit_message_generate "$CHANGES"
83+
```
84+
85+
### Usage tips
86+
87+
The behavior depends on how Git treats files, so you should know these points:
88+
89+
- The commands will pick up on staged changes and certain unstaged changes (modified and deleted, but not created as they are untracked).
90+
- If you want to handle created files, make sure to stage them first.
91+
- If you want to target only select changes for smaller commit, then stage stages and use the `--cached` flag to ignored unstaged changes.
92+
93+
## Uninstall the linked CLI (optional)
94+
95+
```sh
96+
$ npm unlink -g auto-commit-msg
97+
```

docs/development/cli.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# CLI Development
2+
3+
The code is in [src/bin/](/src/bin).
4+
5+
The CLI commands are built using steps set in [package.json](/package.json) - see the `cli*` scripts and `bin` sections.
6+
7+
### Test
8+
9+
Test the TS files directly.
10+
11+
```sh
12+
npx --yes ts-node src/bin/diffIndexGenerate.ts -h
13+
npx --yes ts-node src/bin/diffIndexGenerateCommit.ts -h
14+
npx --yes ts-node src/bin/generate.ts -h
15+
```

0 commit comments

Comments
 (0)