Skip to content

Commit

Permalink
ensure config is generated
Browse files Browse the repository at this point in the history
  • Loading branch information
dkaslovsky committed Feb 11, 2021
1 parent c3d1857 commit 2ff9307
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 6 deletions.
26 changes: 21 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,28 @@ Currently, Vim is the only supported text editor.
## Quick Start
1. Install textnote (see [Installation](#installation))
2. Set a single environment variable `TEXTNOTE_DIR` to specify the directory for textnote's files
3. Start writing notes for today with a single command

That's it, textnote is ready to go!

The directory specified by `TEXTNOTE_DIR` and the default configuration file will be automatically created the first time textnote is run.

Start writing notes for today with a single command
```
$ textnote
```
The directory specified by `TEXTNOTE_DIR` and the default configuration file will be automatically created.

To first configure textnote before creating notes, run
```
$ textnote config -p
```
and then edit the configuration file found at the displayed path.

## Installation
textnote can be installed by downloading a prebuilt binary or by the `go get` command.

### Releases
The recommended installation method is downloading the latest released binary for your operating system.
Download the appropriate binary from this repository's [releases](https://github.com/dkaslovsky/textnote/releases/latest) page or via `curl`:
The recommended installation method is downloading the latest released binary.
Download the appropriate binary for your operating system from this repository's [releases](https://github.com/dkaslovsky/textnote/releases/latest) page or via `curl`:

macOS
```
Expand Down Expand Up @@ -242,7 +254,11 @@ While textnote is intended to be extremely lightweight, it is also designed to b
In particular, the template (sections, headers, date formats, and whitespace) for generating notes can be customized as desired.
One might wish to configure headers and section titles for markdown compatibility or change date formats to match regional convention.

Configuration is read from the `$TEXTNOTE_DIR/.config.yml` file and individual configuration parameters can be overridden with [environment variables](#environment-variable-overrides).
Configuration is read from the `$TEXTNOTE_DIR/.config.yml` file.
Changes to configuration parameters can be made by updating this file.
Individual configuration parameters also can be overridden with [environment variables](#environment-variable-overrides).

Importantly, if textnote's configuration is changed, notes created using a previous configuration might be incompatible with textnote's functionality.

The current configuration can be displayed by running the `config` command:
```
Expand Down
7 changes: 6 additions & 1 deletion cmd/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,19 @@ func CreateConfigCmd() *cobra.Command {
Short: "show configuration",
Long: "displays the application's configuration",
RunE: func(cmd *cobra.Command, args []string) error {
_, err := config.LoadOrCreate()
if err != nil {
return err
}

configPath := filepath.Join(config.AppDir, config.FileName)

if cmdOpts.path {
fmt.Printf("configuration file path: [%s]\n", configPath)
return nil
}

_, err := os.Stat(configPath)
_, err = os.Stat(configPath)
if os.IsNotExist(err) {
return fmt.Errorf("cannot find configuration file [%s]", configPath)
}
Expand Down

0 comments on commit 2ff9307

Please sign in to comment.