Skip to content

Commit

Permalink
Fix the use of comments (#856)
Browse files Browse the repository at this point in the history
* Fix the use of comments

Reflect the lexing change in nushell/nushell#8151 

Addresses nushell/nushell#8731

* Add a warning note to externs

* Add warning note to the command docs

* Fix custom_completions.md

* Fix coloring_and_theming.md

* Fix `0.77` release notes to include the breaking change
  • Loading branch information
sholderbach committed Apr 4, 2023
1 parent 463f7c0 commit 719ebd2
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 30 deletions.
1 change: 1 addition & 0 deletions blog/2023-03-14-nushell_0_77.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ Make sure to browse the help messages of these commands. They contain fully func
# Breaking changes

- Alias changes, see above
- Comments on the same line as code now require a space before ` #` to be recognized as such. This allows you to have a string `foo#bar` with a pound sign. ([#8151](https://github.com/nushell/nushell/pull/8151))
- `env` command has been removed, use `$env` instead (https://github.com/nushell/nushell/pull/8185)
- `str trim` no longer has `--all`, `--both`, and `--format` flags. `str replace` should be an adequate replacement; please let us know if it is not ([#8205](https://github.com/nushell/nushell/pull/8205))
- The changes to timestamp handling noted above ([#8244](https://github.com/nushell/nushell/pull/8244)) can require code changes to existing scripts:
Expand Down
2 changes: 1 addition & 1 deletion book/coloring_and_theming.md
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ Here's another small example using multiple color syntaxes with some comments.
leading_trailing_space_bg: white # this sets only the foreground color in the original style
header: { # this is like PR #489
fg: "#B01455", # note, quotes are required on the values with hex colors
bg: "#ffb900",# note, commas are not required, it could also be all on one line
bg: "#ffb900", # note, commas are not required, it could also be all on one line
attr: bli # note, there are no quotes around this value. it works with or without quotes
}
date: "#75507B"
Expand Down
4 changes: 4 additions & 0 deletions book/custom_commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,10 @@ def greet [

The comments that we put on the definition and its parameters then appear as descriptions inside the [`help`](/commands/docs/help.md) of the command.

::: warning Note
A Nushell comment that continues on the same line for argument documentation purposes requires a space before the ` #` pound sign.
:::

Now, if we run `help greet`, we're given a more helpful help text:

```
Expand Down
4 changes: 2 additions & 2 deletions book/custom_completions.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ If you look closely at the examples in the default config, you'll see this:

```
export extern "git push" [
remote?: string@"nu-complete git remotes", # the name of the remote
refspec?: string@"nu-complete git branches"# the branch / refspec
remote?: string@"nu-complete git remotes", # the name of the remote
refspec?: string@"nu-complete git branches" # the branch / refspec
...
]
```
Expand Down
58 changes: 31 additions & 27 deletions book/externs.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,38 +6,42 @@ This is where `extern` comes in. The `extern` keyword allows you to write a full

```
export extern "git push" [
remote?: string@"nu-complete git remotes", # the name of the remote
refspec?: string@"nu-complete git branches"# the branch / refspec
--verbose(-v) # be more verbose
--quiet(-q) # be more quiet
--repo: string # repository
--all # push all refs
--mirror # mirror all refs
--delete(-d) # delete refs
--tags # push tags (can't be used with --all or --mirror)
--dry-run(-n) # dry run
--porcelain # machine-readable output
--force(-f) # force updates
--force-with-lease: string # require old value of ref to be at this value
--recurse-submodules: string # control recursive pushing of submodules
--thin # use thin pack
--receive-pack: string # receive pack program
--exec: string # receive pack program
--set-upstream(-u) # set upstream for git pull/status
--progress # force progress reporting
--prune # prune locally removed refs
--no-verify # bypass pre-push hook
--follow-tags # push missing but relevant tags
--signed: string # GPG sign the push
--atomic # request atomic transaction on remote side
--push-option(-o): string # option to transmit
--ipv4(-4) # use IPv4 addresses only
--ipv6(-6) # use IPv6 addresses only
remote?: string@"nu-complete git remotes", # the name of the remote
refspec?: string@"nu-complete git branches" # the branch / refspec
--verbose(-v) # be more verbose
--quiet(-q) # be more quiet
--repo: string # repository
--all # push all refs
--mirror # mirror all refs
--delete(-d) # delete refs
--tags # push tags (can't be used with --all or --mirror)
--dry-run(-n) # dry run
--porcelain # machine-readable output
--force(-f) # force updates
--force-with-lease: string # require old value of ref to be at this value
--recurse-submodules: string # control recursive pushing of submodules
--thin # use thin pack
--receive-pack: string # receive pack program
--exec: string # receive pack program
--set-upstream(-u) # set upstream for git pull/status
--progress # force progress reporting
--prune # prune locally removed refs
--no-verify # bypass pre-push hook
--follow-tags # push missing but relevant tags
--signed: string # GPG sign the push
--atomic # request atomic transaction on remote side
--push-option(-o): string # option to transmit
--ipv4(-4) # use IPv4 addresses only
--ipv6(-6) # use IPv6 addresses only
]
```

You'll notice this gives you all the same descriptive syntax that internal commands do, letting you describe flags, short flags, positional parameters, types, and more.

::: warning Note
A Nushell comment that continues on the same line for argument documentation purposes requires a space before the ` #` pound sign.
:::

## Types and custom completions

In the above example, you'll notice some types are followed by `@` followed by the name of a command. We talk more about [custom completions](custom_completions.md) in their own section.
Expand Down

0 comments on commit 719ebd2

Please sign in to comment.