Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .pagerduty.yml.example
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
---
api-token: 'test-api-token'
user-email: 'you@example.com'
33 changes: 33 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ have the following information:
```yaml
---
api-token: <your token>
user-email: <your PagerDuty user email>
```

3. Download the [latest binary release](https://github.com/jdlubrano/pagerduty-cli/releases)
Expand All @@ -27,6 +28,11 @@ and place the binary somewhere in your `$PATH`.
verbose. You can add `alias pd="pagerduty-cli"` to your shell's profile if you
so choose.

The `user-email` value is required for incident write operations in the TUI
because PagerDuty uses it as the `From` header. Protect the configuration file
with `chmod 600 ~/.pagerduty.yml`. You can alternatively set
`PAGERDUTY_API_TOKEN` and `PAGERDUTY_USER_EMAIL` in the environment.

### Upgrading

Upgrading is still a work in progress, so in the meantime, repeat step 3 from
Expand All @@ -41,6 +47,33 @@ strives to be self-service and self-documenting. You can run
commands. You can see additional help for subcommands by running
`pagerduty-cli help <subcommand>`.

### Incident console

Run `pagerduty-cli tui` to open a full-screen terminal console for the newest
100 incidents. The console supports filtering and refreshing incidents,
viewing details and notes, acknowledging and resolving, adding notes and status
updates, reassigning, escalating, snoozing, changing urgency, and opening an
incident in the PagerDuty web UI.

The primary keyboard shortcuts are:

| Key | Action |
|---|---|
| `j` / `k`, arrows | Move through incidents or scroll the focused view |
| `Enter` / `Esc` | Focus incident details / return to the incident list |
| `r` | Refresh |
| `1` | Open incidents (triggered and acknowledged) |
| `2` / `3` / `4` / `5` | Triggered / acknowledged / resolved / all incidents |
| `a` / `x` | Acknowledge / resolve |
| `n` / `p` | Add a note / send a status update |
| `g` / `e` | Reassign / escalate |
| `s` / `u` | Snooze / toggle urgency |
| `o` | Open in the PagerDuty web UI |
| `?` / `q` | Show help / quit |

Without `user-email` (or `PAGERDUTY_USER_EMAIL`), the console remains available
for viewing incidents but disables write actions.

## Development

1. Checkout this repository.
Expand Down
44 changes: 23 additions & 21 deletions cmd/root.go
Original file line number Diff line number Diff line change
@@ -1,35 +1,37 @@
package cmd

import (
"os"
"fmt"
"fmt"
"os"

"github.com/spf13/cobra"
"github.com/spf13/cobra"

"github.com/jdlubrano/pagerduty-cli/cmd/on_call"
"github.com/jdlubrano/pagerduty-cli/cmd/schedules"
"github.com/jdlubrano/pagerduty-cli/cmd/users"
"github.com/jdlubrano/pagerduty-cli/version"
"github.com/jdlubrano/pagerduty-cli/cmd/on_call"
"github.com/jdlubrano/pagerduty-cli/cmd/schedules"
"github.com/jdlubrano/pagerduty-cli/cmd/tui"
"github.com/jdlubrano/pagerduty-cli/cmd/users"
"github.com/jdlubrano/pagerduty-cli/version"
)

func NewRootCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "pagerduty-cli",
Short: "A CLI to interact with Pagerduty",
Long: "A CLI to interact with the Pagerduty API (https://v2.developer.pagerduty.com)",
Version: version.Version,
}
cmd := &cobra.Command{
Use: "pagerduty-cli",
Short: "A CLI to interact with Pagerduty",
Long: "A CLI to interact with the Pagerduty API (https://v2.developer.pagerduty.com)",
Version: version.Version,
}

cmd.AddCommand(on_call.NewOnCallCmd())
cmd.AddCommand(schedules.NewSchedulesCmd())
cmd.AddCommand(users.NewUsersCmd())
cmd.AddCommand(on_call.NewOnCallCmd())
cmd.AddCommand(schedules.NewSchedulesCmd())
cmd.AddCommand(tui.NewTUICmd())
cmd.AddCommand(users.NewUsersCmd())

return cmd
return cmd
}

func Execute() {
if err := NewRootCmd().Execute(); err != nil {
fmt.Println(err)
os.Exit(1)
}
if err := NewRootCmd().Execute(); err != nil {
fmt.Println(err)
os.Exit(1)
}
}
Loading