Skip to content

Commit

Permalink
readme
Browse files Browse the repository at this point in the history
  • Loading branch information
TanklesXL committed Jun 20, 2024
1 parent d4675dc commit f0bad39
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ The general workflow involves

### Help text

Glint automatically generates help text for your commands and flags. Help text is both automatically formatted and wrapped. You can attach help text to your commands and flags with the functions described below.

_**Note**_:Help text is generated and printed whenever a glint command is called with the built-in flag `--help`. It is also printed after the error text when any errors are encountered due to invalid flags or arguments.

Help text descriptions can be attached to all of glint's components:
Expand All @@ -41,6 +43,34 @@ Help text descriptions can be attached to all of glint's components:
- attach flag help text with `glint.flag_help`
- attach help text to a non-initialized command with `glint.path_help`

#### Help text formatting

It is not uncommon for developers to want to format long text strings in such a way that it is easier to read in a code editor. Glint accounts for this be being sensitive to multiple line breaks in a help text string. This means that text like the following:

```
A very very very very very very very long help text
string that is too long to fit on one line.
Here is something that gets its own line.
And here is something that gets its own paragraph.
```

Will be formatted as follows:

```
A very very very very very very very long help text
string that is too long to fit on one line.
Here is something that gets its own line.
And here is something that gets its own paragraph.
```

#### Help text wrapping

In addition to newline formatting, glint also handles wrapping helptext so that it fits within the configured terminal width. This means that if you have a long help text string it will be adjusted to fit on additional lines if it is too long to fit on one line. Spacing is also added to keep descriptions aligned with each other.

### Mini Example

You can import `glint` as a dependency and use it to build command-line applications like the following simplified version of the [the hello world example](./test/examples/hello.gleam).
Expand Down
3 changes: 3 additions & 0 deletions src/glint/internal/utils.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ fn do_wordwrap(
}
}

/// splis a string for consecutive newline groups
/// replaces individual newlines with a spacet
/// groups of newlines > 1 are replaced with n-2 newlines followed by a new item
pub fn space_split_lines(s: String) -> List(String) {
{
s
Expand Down

0 comments on commit f0bad39

Please sign in to comment.