Skip to content

dev/sg: update categories, clean up 'sg page' command

Administrator requested to merge sg-cleanup into main

Created by: bobheadxi

Was going through this with @marekweb and noticed some changes to make:

  1. Some commands were miscategorized - I've moved feedback and analytics to Utilities, and page to Company (it is specific to Sourcegraph), and also removed the long-deprecated doctor command
  2. Removed unnecessary global variables from sg page
  3. sg page <schedule> should be command, since semantically you "page " and provide additional options on top, so this command removes the responders.* flags in favour of:
    sg page dev-experience-support --escalation "another-team" --escalation "yet-another-team"
  4. Add aliases for some flags
  5. Add env var source for opsgenie token
  6. Remove and ban usage of log.Fatal in sg, since that breaks background jobs

Test plan

$ go run ./dev/sg page -h                                     
NAME:
   sg page - Page engineers at Sourcegraph - mostly used within scripts to automate paging alerts

USAGE:
   sg page --opsgenie.token [TOKEN] --message "something is broken" [my-schedule-on-ops-genie]

CATEGORY:
   2 - Company

OPTIONS:
   --opsgenie.token value         OpsGenie token [$SG_OPSGENIE_TOKEN]
   --message value, -m value      Message for the paging alert
   --description value, -d value  Description for the paging alert (optional)
   --priority value, -p value     Alert priority, importance decreases from P1 (critical) to P5 (lowest), defaults to P5 (default: "P5")
   --url value                    URL field for alert details (optional)
   --escalation value             Escalation team(s) to alert  (accepts multiple inputs)
   --feedback                     provide feedback about this command by opening up a Github discussion (default: false)
   --help, -h                     show help (default: false)
$ go run ./dev/sg help                                          
NAME:
   sg - The Sourcegraph developer tool!

USAGE:
   sg [global options] command [command options] [arguments...]

DESCRIPTION:
   Learn more: https://docs.sourcegraph.com/dev/background-information/sg

COMMANDS:
   1 - Development:
     start          🌟 Starts the given commandset. Without a commandset it starts the default Sourcegraph dev environment
     run            Run the given commands
     ci             Interact with Sourcegraph's Buildkite continuous integration pipelines
     test           Run the given test suite
     lint           Run all or specified linters on the codebase
     generate, gen  Run code and docs generation tasks
     db             Interact with local Sourcegraph databases for development
     migration      Modifies and runs database migrations
     insights       Tools to interact with Code Insights data
     telemetry      Operations relating to Sourcegraph telemetry
   2 - Company:
     teammate  Get information about Sourcegraph teammates
     rfc       List, search, and open Sourcegraph RFCs
     adr       List, search, view, and create Sourcegraph Architecture Decision Records (ADRs)
     live      Reports which version of Sourcegraph is currently live in the given environment
     ops       Commands used by operations teams to perform common tasks
     page      Page engineers at Sourcegraph - mostly used within scripts to automate paging alerts
   3 - Environment:
     secret  Manipulate secrets stored in memory and in file
     setup   Validate and set up your local dev environment!
   4 - Utilities:
     help       Get help and docs about sg
     feedback   Provide feedback about sg
     version    View details for this installation of sg
     update     Update local sg installation
     logo       Print the sg logo
     analytics  Manage analytics collected by sg

GLOBAL OPTIONS:
   --verbose, -v               toggle verbose mode (default: false) [$SG_VERBOSE]
   --config file, -c file      load sg configuration from file (default: "sg.config.yaml") [$SG_CONFIG]
   --overwrite file, -o file   load sg configuration from file that is gitignored and can be used to, for example, add credentials (default: "sg.config.overwrite.yaml") [$SG_OVERWRITE]
   --disable-overwrite         disable loading additional sg configuration from overwrite file (see -overwrite) (default: false) [$SG_DISABLE_OVERWRITE]
   --skip-auto-update          prevent sg from automatically updating itself (default: true) [$SG_SKIP_AUTO_UPDATE]
   --disable-analytics         disable event logging (logged to '~/.sourcegraph/events') (default: true) [$SG_DISABLE_ANALYTICS]
   --disable-output-detection  use fixed output configuration instead of detecting terminal capabilities (default: false) [$SG_DISABLE_OUTPUT_DETECTION]

Merge request reports

Loading