Commit Graph

8 Commits

Author SHA1 Message Date
Paul C. Roberts fdd2d8eb39
Add vim shortcuts and Home and End Keys to terminal ()
<!--- 
Thanks so much for your contribution! If this is your first time
contributing, please ensure that you have read the
[CONTRIBUTING](https://github.com/pulumi/pulumi/blob/master/CONTRIBUTING.md)
documentation.
-->

# Description

Updates the terminal support for the tree view in Pulumi CLI

This adds the vim shortcuts :
`j` &ndash; down
`k` &ndash; up
`Ctrl+F` &ndash; page down 
`Ctrl+B` &ndash; page up
`g` &ndash; home
`G` &ndash; end

Also adds Home and End key support

Fixes # (issue)

## Checklist

- [X] I have run `make tidy` to update any new dependencies
- [X] I have run `make lint` to verify my code passes the lint check
  - [ ] I have formatted my code using `gofumpt`

<!--- Please provide details if the checkbox below is to be left
unchecked. -->
- [X] I have added tests that prove my fix is effective or that my
feature works
<!--- 
User-facing changes require a CHANGELOG entry.
-->
- [X] I have run `make changelog` and committed the
`changelog/pending/<file>` documenting my change
<!--
If the change(s) in this PR is a modification of an existing call to the
Pulumi Cloud,
then the service should honor older versions of the CLI where this
change would not exist.
You must then bump the API version in
/pkg/backend/httpstate/client/api.go, as well as add
it to the service.
-->
- [ ] Yes, there are changes in this PR that warrants bumping the Pulumi
Cloud API version
<!-- @Pulumi employees: If yes, you must submit corresponding changes in
the service repo. -->

Co-authored-by: Paul Roberts <proberts@pulumi.com>
2024-02-24 08:31:36 +00:00
Thomas Gummerer baecc85eaf
turn on the golangci-lint exhaustive linter ()
Turn on the golangci-lint exhaustive linter.  This is the first step
towards catching more missing cases during development rather than
in tests, or in production.

This might be best reviewed commit-by-commit, as the first commit turns
on the linter with the `default-signifies-exhaustive: true` option set,
which requires a lot less changes in the current codebase.

I think it's probably worth doing the second commit as well, as that
will get us the real benefits, even though we end up with a little bit
more churn. However it means all the `switch` statements are covered,
which isn't the case after the first commit, since we do have a lot of
`default` statements that just call `assert.Fail`.
 
Fixes  

## Checklist

- [x] I have run `make tidy` to update any new dependencies
- [x] I have run `make lint` to verify my code passes the lint check
  - [x] I have formatted my code using `gofumpt`

<!--- Please provide details if the checkbox below is to be left
unchecked. -->
- [ ] I have added tests that prove my fix is effective or that my
feature works
<!--- 
User-facing changes require a CHANGELOG entry.
-->
- [ ] I have run `make changelog` and committed the
`changelog/pending/<file>` documenting my change
<!--
If the change(s) in this PR is a modification of an existing call to the
Pulumi Cloud,
then the service should honor older versions of the CLI where this
change would not exist.
You must then bump the API version in
/pkg/backend/httpstate/client/api.go, as well as add
it to the service.
-->
- [ ] Yes, there are changes in this PR that warrants bumping the Pulumi
Cloud API version
<!-- @Pulumi employees: If yes, you must submit corresponding changes in
the service repo. -->
2024-01-17 16:50:41 +00:00
Fraser Waters 16d9f4c167
Enable perfsprint linter ()
<!--- 
Thanks so much for your contribution! If this is your first time
contributing, please ensure that you have read the
[CONTRIBUTING](https://github.com/pulumi/pulumi/blob/master/CONTRIBUTING.md)
documentation.
-->

# Description

<!--- Please include a summary of the change and which issue is fixed.
Please also include relevant motivation and context. -->

Prompted by a comment in another review:
https://github.com/pulumi/pulumi/pull/14654#discussion_r1419995945

This lints that we don't use `fmt.Errorf` when `errors.New` will
suffice, it also covers a load of other cases where `Sprintf` is
sub-optimal.

Most of these edits were made by running `perfsprint --fix`.

## Checklist

- [x] I have run `make tidy` to update any new dependencies
- [x] I have run `make lint` to verify my code passes the lint check
  - [x] I have formatted my code using `gofumpt`

<!--- Please provide details if the checkbox below is to be left
unchecked. -->
- [ ] I have added tests that prove my fix is effective or that my
feature works
<!--- 
User-facing changes require a CHANGELOG entry.
-->
- [ ] I have run `make changelog` and committed the
`changelog/pending/<file>` documenting my change
<!--
If the change(s) in this PR is a modification of an existing call to the
Pulumi Cloud,
then the service should honor older versions of the CLI where this
change would not exist.
You must then bump the API version in
/pkg/backend/httpstate/client/api.go, as well as add
it to the service.
-->
- [ ] Yes, there are changes in this PR that warrants bumping the Pulumi
Cloud API version
<!-- @Pulumi employees: If yes, you must submit corresponding changes in
the service repo. -->
2023-12-12 12:19:42 +00:00
Pat Gavlin 2bad0a85e8 [cli] Add an "open in browser" keybinding
Add support for using Ctrl+O to open the current update in the browser
for backends that support permalinks.

The keybinding is advertised in the interactive display as part of the
message that displays the permalink:

```
Previewing update (dev)

View in Browser (Ctrl+O): https://<some-url>

     Type                          Name      Plan
 +   pulumi:pulumi:Stack           vpc-dev   create
 +   ├─ aws:ec2:Vpc                vpc       create
 +   ├─ aws:ec2:SecurityGroup      secgroup  create
 +   ├─ aws:ec2:SecurityGroupRule  rule-2    create
 +   ├─ aws:ec2:SecurityGroupRule  rule-0    create
 +   ├─ aws:ec2:SecurityGroupRule  rule-1    create
 +   └─ aws:ec2:SecurityGroupRule  rule-3    create
```

In order to maintain backwards compatibility with older versions of the
Automation API, the message is not changed for non-interactive
scenarios.
2023-03-09 15:52:13 -08:00
Pat Gavlin 5c77ce69fc [cli] Add autoscrolling and support page-{down,up}
- If the display is scrolled to the bottom, autoscroll it as new lines are
  added to the output.

- Add support for scrolling the interactive display using page-down and
  page-up. These keys scroll the display N lines at a time, where N is the
  height of the terminal.
2023-03-07 12:16:02 -08:00
Pat Gavlin f92cb3d5d0 [display] Hide the cursor in interactive mode.
Hiding the cursor should eliminate the last of the redraw artifacts.
2022-12-20 10:56:59 -08:00
Pat Gavlin 4fcf040ade [display] Overwrite terminal contents
Instead of clearing the contents of the display with each frame,
overwrite its contents by clearing to the end of each line prior to a
newline. This should eliminate flickering in the interactive display.

This also eliminates a couple of off-by-one errors that were hampering
usability.
2022-12-20 10:27:31 -08:00
Pat Gavlin a20ddffde5 [cli] Abstract out terminal interactions
Replace direct interaction with the terminal with an abstraction. This
abstraction is tightly constrained to the capabilities needed for the
CLI's display. Using this abstraction allows for straightforward testing
of the interactive renderers.
2022-11-08 17:13:56 -08:00