Skip to content

Commit

Permalink
docs: fix typos
Browse files Browse the repository at this point in the history
  • Loading branch information
kbknapp committed Jul 8, 2024
1 parent 1aa61fa commit 9afcb74
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 46 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/ci-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ jobs:

- name: Check spelling
uses: crate-ci/typos@master
with:
config: ./.typos.toml

- name: Install Rust
uses: dtolnay/rust-toolchain@stable
Expand Down
3 changes: 3 additions & 0 deletions .typos.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[type.md.extend-words]
ba = "ba"
afe = "afe"
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ There are two ways to use `clog`, as a binary via the command line or as a libra

### Binary (Command Line)

In order to use `clog` via the command line you must first obtain a binary by either compiling it yourself, or downlading and installing one of the precompiled binaries.
In order to use `clog` via the command line you must first obtain a binary by either compiling it yourself, or downloading and installing one of the precompiled binaries.

#### `cargo install`

Expand Down Expand Up @@ -87,7 +87,7 @@ Otherwise, ensure you have the `clog` binary in the directory which you operatin

#### Using clog from the Command Line

`clog` works by reading your `git` metadata and specially crafted commit messages and subjects to create a changelog. `clog` has the following options availble.
`clog` works by reading your `git` metadata and specially crafted commit messages and subjects to create a changelog. `clog` has the following options available.

```sh
USAGE:
Expand All @@ -104,7 +104,7 @@ FLAGS:
OPTIONS:
-C, --changelog <changelog> A previous changelog to prepend new changes to (this is like
using the same file for both --infile and --outfile and
should not be used in conjuction with either)
should not be used in conjunction with either)
-c, --config <config> The Clog Configuration TOML file to use (Defaults to
'.clog.toml')**
-T, --format <format> The output format, defaults to markdown
Expand Down Expand Up @@ -175,7 +175,7 @@ subtitle = "my awesome title"
link-style = "github"
# The preferred way to set a constant changelog. This file will be read for old changelog
# data, then prepended to for new changelog data. It's the equivilant to setting
# data, then prepended to for new changelog data. It's the equivalent to setting
# both infile and outfile to the same file.
#
# Do not use with outfile or infile fields!
Expand Down Expand Up @@ -223,7 +223,7 @@ MySection = ["mysec", "ms"]
Now if you make a commit message such as `mysec(Component): some message` or `ms(Component): some message` there will be a new "MySection" section along side the "Features" and "Bug Fixes" areas.
*NOTE:* Sections with spaces are suppported, such as `"My Special Section" = ["ms", "mysec"]`
*NOTE:* Sections with spaces are supported, such as `"My Special Section" = ["ms", "mysec"]`
## Companion Projects
Expand Down
9 changes: 5 additions & 4 deletions src/error.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::convert::From;
use std::error::Error;
use std::fmt::{Display, Formatter};
use std::fmt::Result as FmtResult;
use std::fmt::{Display, Formatter};

use clog::error::Error as ClogErr;

Expand All @@ -12,7 +12,7 @@ use fmt::Format;
pub enum CliError {
Semver(Box<dyn Error>, String),
Generic(String),
Unknown
Unknown,
}

// Copies clog::error::Error;
Expand Down Expand Up @@ -50,8 +50,9 @@ impl Error for CliError {
match *self {
CliError::Semver(_, ref s) => &*s,
CliError::Generic(ref d) => &*d,
CliError::Unknown =>
"An unknown fatal error has occurred, please consider filing a bug-report!",
CliError::Unknown => {
"An unknown fatal error has occurred, please consider filing a bug-report!"
}
}
}

Expand Down
80 changes: 43 additions & 37 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#[macro_use]
extern crate clap;
extern crate time;
extern crate clog;
extern crate semver;
#[cfg(feature = "color")]
extern crate ansi_term;
extern crate clog;
extern crate semver;
extern crate time;

use clap::{App, Arg, ArgGroup, ArgMatches};

use clog::{LinkStyle, Clog};
use clog::fmt::ChangelogFormat;
use clog::{Clog, LinkStyle};

#[macro_use]
mod macros;
Expand Down Expand Up @@ -46,7 +46,7 @@ fn main() {
-i, --infile [FILE] 'A changelog to append to, but *NOT* write to (Useful in \
conjunction with --outfile)'
--setversion [VER] 'e.g. 1.0.1'")
// Because --from-latest-tag can't be used with --from, we add it seperately so we can
// Because --from-latest-tag can't be used with --from, we add it separately so we can
// specify a .conflicts_with()
.arg(Arg::from_usage("-F, --from-latest-tag 'use latest tag as start (instead of --from)'")
.conflicts_with("from"))
Expand All @@ -58,7 +58,7 @@ fn main() {
// to conflicting lists
.arg(Arg::from_usage("-C, --changelog [FILE] 'A previous changelog to prepend new changes to (this is like \
using the same file for both --infile and --outfile and \
should not be used in conjuction with either)'")
should not be used in conjunction with either)'")
.conflicts_with("infile")
.conflicts_with("outfile"))
// Since --setversion shouldn't be used with any of the --major, --minor, or --match, we
Expand Down Expand Up @@ -111,34 +111,40 @@ pub fn from_matches(matches: &ArgMatches) -> CliResult<Clog> {
let mut clog = if let Some(cfg) = matches.value_of("config") {
debugln!("User passed in config file: {:?}", cfg);
if matches.is_present("work-dir") && matches.is_present("gitdir") {
debugln!("User passed in both\n\tworking dir: {:?}\n\tgit dir: {:?}",
matches.value_of("work-dir"),
matches.value_of("git-dir"));
// use --config --work-tree --git-dir
Clog::with_all(matches.value_of("git-dir").unwrap(),
matches.value_of("work-dir").unwrap(),
cfg)?
debugln!(
"User passed in both\n\tworking dir: {:?}\n\tgit dir: {:?}",
matches.value_of("work-dir"),
matches.value_of("git-dir")
);
// use --config --work-tree --git-dir
Clog::with_all(
matches.value_of("git-dir").unwrap(),
matches.value_of("work-dir").unwrap(),
cfg,
)?
} else if let Some(dir) = matches.value_of("work-dir") {
debugln!("User passed in working dir: {:?}", dir);
// use --config --work-tree
// use --config --work-tree
Clog::with_dir_and_file(dir, cfg)?
} else if let Some(dir) = matches.value_of("git-dir") {
debugln!("User passed in git dir: {:?}", dir);
// use --config --git-dir
// use --config --git-dir
Clog::with_dir_and_file(dir, cfg)?
} else {
debugln!("User only passed config");
// use --config only
// use --config only
Clog::from_file(cfg)?
}
} else {
debugln!("User didn't pass in a config");
if matches.is_present("git-dir") && matches.is_present("work-dir") {
let wdir = matches.value_of("work-dir").unwrap();
let gdir = matches.value_of("git-dir").unwrap();
debugln!("User passed in both\n\tworking dir: {:?}\n\tgit dir: {:?}",
wdir,
gdir);
debugln!(
"User passed in both\n\tworking dir: {:?}\n\tgit dir: {:?}",
wdir,
gdir
);
Clog::with_dirs(gdir, wdir)?
} else if let Some(dir) = matches.value_of("git-dir") {
debugln!("User passed in git dir: {:?}", dir);
Expand All @@ -155,9 +161,11 @@ pub fn from_matches(matches: &ArgMatches) -> CliResult<Clog> {
// compute version early, so we can exit on error
clog.version = {
// less typing later...
let (major, minor, patch) = (matches.is_present("major"),
matches.is_present("minor"),
matches.is_present("patch"));
let (major, minor, patch) = (
matches.is_present("major"),
matches.is_present("minor"),
matches.is_present("patch"),
);
if matches.is_present("setversion") {
matches.value_of("setversion").unwrap().to_owned()
} else if major || minor || patch {
Expand All @@ -174,34 +182,32 @@ pub fn from_matches(matches: &ArgMatches) -> CliResult<Clog> {
Ok(ref mut v) => {
// if-else may be quicker, but it's longer mentally, and this isn't slow
match (major, minor, patch) {
(true,_,_) => {
(true, _, _) => {
v.major += 1;
v.minor = 0;
v.patch = 0;
}
(_,true,_) => {
(_, true, _) => {
v.minor += 1;
v.patch = 0;
}
(_,_,true) => {
(_, _, true) => {
v.patch += 1;
clog.patch_ver = true;
}
_ => unreachable!(),
}
format!("{}{}",
if had_v {
"v"
} else {
""
},
v)
format!("{}{}", if had_v { "v" } else { "" }, v)
}
Err(e) => {
return Err(CliError::Semver(Box::new(e),
String::from("Failed to parse version into \
return Err(CliError::Semver(
Box::new(e),
String::from(
"Failed to parse version into \
valid SemVer. Ensure the version \
is in the X.Y.Z format.")));
is in the X.Y.Z format.",
),
));
}
}
} else {
Expand All @@ -224,8 +230,8 @@ pub fn from_matches(matches: &ArgMatches) -> CliResult<Clog> {
}

if matches.is_present("link-style") {
clog.link_style = value_t!(matches.value_of("link-style"), LinkStyle)
.unwrap_or(LinkStyle::Github);
clog.link_style =
value_t!(matches.value_of("link-style"), LinkStyle).unwrap_or(LinkStyle::Github);
}

if let Some(subtitle) = matches.value_of("subtitle") {
Expand Down

0 comments on commit 9afcb74

Please sign in to comment.