Skip to content

Commit ef184ba

Browse files
committed
docs: adds initial documentation
1 parent a790b70 commit ef184ba

File tree

6 files changed

+678
-27
lines changed

6 files changed

+678
-27
lines changed

Cargo.toml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,19 @@ description = "A conventional changelog for the rest of us"
1111

1212
[dependencies]
1313
regex = "*"
14-
time = "*"
15-
clap = "*"
1614
semver = "*"
1715
toml = "*"
16+
clap = "*"
17+
time = "*"
1818

1919
[dependencies.regex_macros]
20+
version = "*"
2021
optional = true
2122

2223
[features]
2324
default=[]
25+
26+
# For debugging output
2427
debug=[]
2528

2629
# for building with nightly and unstable features

README.md

Lines changed: 77 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,29 +20,45 @@ The way this works, is every time you make a commit, you ensure your commit subj
2020

2121
### Usage
2222

23+
There are two ways to use `clog`, via the command line or a library in your applicaitons.
24+
25+
#### Command Line
26+
2327
```
2428
USAGE:
25-
clog [FLAGS] [OPTIONS]
29+
clog [FLAGS] [OPTIONS]
2630
2731
FLAGS:
28-
--from-latest-tag use latest tag as start (instead of --from)
32+
-c, --config The Clog Configuration TOML file to use (Defaults to '.clog.toml')**
33+
-F, --from-latest-tag use latest tag as start (instead of --from)
2934
-h, --help Prints help information
30-
--major Increment major version by one (Sets minor and patch to 0)
31-
--minor Increment minor version by one (Sets patch to 0)
32-
--patch Increment patch version by one
33-
-v, --version Prints version information
35+
-M, --major Increment major version by one (Sets minor and patch to 0)
36+
-m, --minor Increment minor version by one (Sets patch to 0)
37+
-p, --patch Increment patch version by one
38+
-V, --version Prints version information
3439
3540
OPTIONS:
36-
--from <from> e.g. 12a8546
41+
-f, --from <from> e.g. 12a8546
42+
-g, --git-dir <gitdir> Local .git directory (defaults to current dir + '.git')*
3743
-o, --outfile <outfile> Where to write the changelog (Defaults to 'changelog.md')
38-
-r, --repository <repository> e.g. https://github.com/thoughtram/clog
39-
--link-style <style> The commit link style to use, defaults to github [values: Github, Gitlab, Stash]
40-
--subtitle <subtitle> e.g. crazy-release-title
41-
--to <to> e.g. 8057684 (Defaults to HEAD when omitted)
44+
-r, --repository <repo> Repo used for link generation (without the .git, e.g. https://github.com/thoughtram/clog)
45+
-l, --link-style <style> The style of repository link to generate (Defaults to github) [values: Github, Gitlab, Stash]
46+
-s, --subtitle <subtitle> e.g. "Crazy Release Title"
47+
-t, --to <to> e.g. 8057684 (Defaults to HEAD when omitted)
4248
--setversion <ver> e.g. 1.0.1
49+
-w, --work-tree <workdir> Local working tree of the git project (defaults to current dir)*
50+
51+
* If your .git directory is a child of your project directory (most common, such as
52+
/myproject/.git) AND not in the current working directory (i.e you need to use --work-tree or
53+
--git-dir) you only need to specify either the --work-tree (i.e. /myproject) OR --git-dir (i.e.
54+
/myproject/.git), you don't need to use both.
55+
56+
** If using the --config to specify a clog configuration TOML file NOT in the current working
57+
directory (meaning you need to use --work-tree or --git-dir) AND the TOML file is inside your
58+
project directory (i.e. /myproject/.clog.toml) you do not need to use --work-tree or --git-dir.
4359
```
4460

45-
### Try it!
61+
##### Try it!
4662

4763
1. Clone the repo `git clone https://github.com/thoughtram/clog && cd clog`
4864

@@ -52,6 +68,55 @@ OPTIONS:
5268

5369
3. Run clog `./target/release/clog -r https://github.com/thoughtram/clog --setversion 0.1.0 --subtitle crazy-dog --from 6d8183f`
5470

71+
#### As a Library
72+
73+
See the documentation for information on using `clog` in your applications.
74+
75+
##### Try it!
76+
77+
1. Clone the `clog` repo so that you have something to search through (Because `clog` uses
78+
specially formatted commit messages)
79+
```
80+
$ git clone https://github.com/thoughtram/clog ~/clog
81+
```
82+
83+
2. Add `clog` as a dependency in your `Cargo.toml`
84+
85+
```toml
86+
[dependencies]
87+
clog = "*"
88+
```
89+
90+
3. Use the following in your `src/main.rs`
91+
92+
```rust
93+
extern crate clog;
94+
95+
use clog::Clog;
96+
97+
fn main() {
98+
// Create the struct
99+
let mut clog = Clog::with_dir("~/clog").unwrap_or_else(|e| {
100+
println!("{}",e);
101+
std::process::exit(1);
102+
});
103+
104+
// Set some options
105+
clog.repository("https://github.com/thoughtram/clog")
106+
.subtitle("Crazy Dog")
107+
.from("6d8183f")
108+
.version("0.1.0");
109+
110+
// Write the changelog to the current working directory
111+
//
112+
// Alternatively we could have used .write_changelog_to("/somedir/some_file.md")
113+
clog.write_changelog();
114+
}
115+
```
116+
117+
4. Compile and run `$ cargo build --release && ./target/release/bin_name
118+
5. View the output in your favorite markdown viewer! `$ vim changelog.md`
119+
55120
### Default Options
56121

57122
`clog` can also be configured using a default configuration file so that you don't have to specify all the options each time you want to update your changelog. To do this add a `.clog.toml` file to your repository.

0 commit comments

Comments
 (0)