{"id":29935117,"url":"https://github.com/abicky/pd-shift","last_synced_at":"2025-08-02T20:34:58.573Z","repository":{"id":303017257,"uuid":"998596140","full_name":"abicky/pd-shift","owner":"abicky","description":"A CLI tool for managing PagerDuty on-call shifts","archived":false,"fork":false,"pushed_at":"2025-07-05T06:50:05.000Z","size":163,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-07-05T07:34:15.900Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/abicky.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-06-08T23:58:40.000Z","updated_at":"2025-07-05T06:50:06.000Z","dependencies_parsed_at":"2025-07-05T16:15:50.779Z","dependency_job_id":null,"html_url":"https://github.com/abicky/pd-shift","commit_stats":null,"previous_names":["abicky/pd-shift"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/abicky/pd-shift","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abicky%2Fpd-shift","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abicky%2Fpd-shift/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abicky%2Fpd-shift/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abicky%2Fpd-shift/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/abicky","download_url":"https://codeload.github.com/abicky/pd-shift/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abicky%2Fpd-shift/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268448362,"owners_count":24252019,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-02T02:00:12.353Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-08-02T20:34:57.903Z","updated_at":"2025-08-02T20:34:58.562Z","avatar_url":"https://github.com/abicky.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pd-shift\n\n[![main](https://github.com/abicky/pd-shift/actions/workflows/main.yaml/badge.svg)](https://github.com/abicky/pd-shift/actions/workflows/main.yaml)\n\n`pd-shift` is a CLI tool for managing PagerDuty on-call shifts.\n\n## Installation\n\n### Precompiled binary\n\nDownload the binary archive from the [releases page](https://github.com/abicky/pd-shift/releases), unpack it, and move the `pd-shift` executable to a directory in your `PATH` (e.g. `/usr/local/bin`).\n\nFor example, you can install the latest binary on a Mac with Apple silicon by running the following commands:\n\n```sh\ncurl -LO https://github.com/abicky/pd-shift/releases/latest/download/pd-shift_darwin_arm64.tar.gz\ntar xvf pd-shift_darwin_arm64.tar.gz\nmv pd-shift_darwin_arm64/pd-shift /usr/local/bin/\n```\n\nIf you downloaded the archive via a browser on Mac, you may see the error\n\n\u003e “pd-shift” cannot be opened because the developer cannot be verified.\n\nTo resolve this, remove the \"com.apple.quarantine\" attribute:\n\n```sh\nxattr -d com.apple.quarantine /path/to/pd-shift\n```\n\n### Homebrew\n\n```sh\nbrew install abicky/tools/pd-shift\n```\n\n### Docker\n\nYou can also run `pd-shift` via Docker. For example, to show the help message:\n\n\n```sh\ndocker run --rm abicky/pd-shift --help\n```\n\n### From source\n\n```sh\ngo install github.com/abicky/pd-shift@latest\n```\n\nOr clone and build manually:\n\n```sh\ngit clone https://github.com/abicky/pd-shift\ncd pd-shift\nmake install\n```\n\n## Usage\n\n### Authentication\n\npd-shift uses a PagerDuty REST API key. You can provide it using either of the `--api-key` global flag, the `PD_SHIFT_API_KEY` environment variable, or the `api-key` field in a config file.\nIf you don't have a key, see the [PagerDuty document](https://support.pagerduty.com/main/docs/api-access-keys#rest-api-keys) to generate one.\n\n### Configurations\n\n Property               | Required | Default           | Description\n------------------------|----------|-------------------|-------------------\n api-key                | ✔        |                   | PagerDuty API key.\n config                 |          | See below         | Path to the config file.\n count.time-zone        |          | UTC               | Time zone used for `handoff-times`, `since`, and `until`.\n count.schedule-ids     | ✔        |                   | List of scheduled IDs to include in the count.\n count.handoff-times    | ✔        |                   | List of handoff times. For example, if the day shift starts at 05:00 and the night shift starts at 17:00, the value should be `[\"05:00\", \"17:00\"]`.\n count.include          |          | `[]` (all shifts) | List of shifts to count. Each item is in the format `\u003cday-type\u003e:\u003cstart-handoff-time\u003e-\u003cend-handoff-time\u003e`, where the time range is optional. For example, `[\"working-days:17:00-05:00\", \"non-working-days\"]` counts night shifts on working days and all shifts on non-working days.\n count.non-working-days |          | `[]`              | List of non-working days used by `count.include`. \"JP holidays\", weekdays (e.g. \"Sat\", \"Sun\"), and specific dates (e.g. \"Dec 31\", \"Jan 1\") are supported.\n count.since            | ✔        |                   | Start of the date range for counting on-call shifts. For example, if `since` is \"2025-01-01\" and the first handoff time is \"05:00\", counting starts from 2025-01-01 05:00.\n count.until            | ✔        |                   | End of the date range for counting on-call shifts. For example, if `until` is \"2025-02-01\" and the first handoff time is \"05:00\", counting ends at 2025-02-01 05:00.\n\npd-shift loads configuration values in the following order of precedence:\n\n1. Command line flags\n    - The flag name matchjes the property name, excluding any subcommand name prefix.\n2. Environment variables\n    - The environment variable name is in the format `PD_SHIFT_\u003cPROPERTY_NAME\u003e`, where property names are uppercased and dots are replaced with underscores. (e.g. `PD_SHIFT_COUNT_TIME_ZONE`).\n3. Config file\n    - pd-shift searches for a config file named \"config\" (e.g., config.yaml) in a pd-shift directory, following the [XDG base directory specification](https://specifications.freedesktop.org/basedir-spec/0.8/)  (e.g., `$HOME/.config/pd-shift/config.yaml`).\n    - Supported formats are those supported by [Viper](https://github.com/spf13/viper).\n\nHere is an example config file in YAML format:\n\n```yaml\n# For the count subcommand\ncount:\n  time-zone: Asia/Tokyo\n  schedule-ids:\n    - P4DRALL\n  handoff-times:\n    - 05:00\n    - 17:00\n  include:\n    - working-days:17:00-05:00\n    - non-working-days\n  non-working-days:\n    - JP holidays\n    - Sat\n    - Sun\n    - Dec 29\n    - Dec 30\n    - Dec 31\n    - Jan 1\n    - Jan 2\n    - Jan 3\n```\n\n### Completions\n\nThe `completion` subcommand generates an autocompletion script. For example, you can generate the autocompletion script for zsh as follows:\n\n```sh\npd-shift completion zsh \u003e /usr/local/share/zsh/site-functions/_pd-shift\n```\n\nIf installed via Homebrew, autocompletion scripts are generated automatically.\n\n### Count subcommand\n\nThis command subcommand counts PagerDuty on-call shifts based on the specified configuration.\n\nAssume the following scenario:\n\n* You want to count day shifts on working days and all shifts on non-working days.\n* Day shifts start at 05:00, and night shifts start at 17:00.\n* Non-working days include Japanese holidays, weekends, and the following dates: December 29, 30, 31, and January 1, 2 and 3.\n* The target period is from 2025-07-01 to 2025-07-08.\n* The target schedule is as follows:\n    ![](images/schedule.png)\n\nTo count the shifts in this case, run:\n\n```console\npd-shift count \\\n  --time-zone Asia/Tokyo \\\n  --schedule-ids P4DRALL \\\n  --handoff-times 05:00,17:00 \\\n  --include working-days:17:00-05:00,non-working-days \\\n  --non-working-days 'JP holidays,Sat,Sun,Dec 29,Dec 30,Dec 31,Jan 1,Jan 2,Jan 3' \\\n  --since 2025-07-01 \\\n  --until 2025-07-08\n```\n\nThis produces the following output:\n\n```\n# Summary\n\n- John Smith: 7.50\n- Takeshi Arabiki: 1.50\n- Total: 9.00\n- Expected total: 9\n\n# Details\n\n- Tue, 2025-07-01 17:00+0900 - Wed, 2025-07-02 05:00+0900\n    - Weekly Rotation\n        - John Smith: 1.00 (17:00 - 05:00)\n- Wed, 2025-07-02 17:00+0900 - Thu, 2025-07-03 05:00+0900\n    - Weekly Rotation\n        - John Smith: 1.00 (17:00 - 05:00)\n- Thu, 2025-07-03 17:00+0900 - Fri, 2025-07-04 05:00+0900\n    - Weekly Rotation\n        - John Smith: 1.00 (17:00 - 05:00)\n- Fri, 2025-07-04 17:00+0900 - Sat, 2025-07-05 05:00+0900\n    - Weekly Rotation\n        - John Smith: 1.00 (17:00 - 05:00)\n- Sat, 2025-07-05 05:00+0900 - Sat, 2025-07-05 17:00+0900\n    - Weekly Rotation\n        - John Smith: 0.33 (05:00 - 09:00)\n        - Takeshi Arabiki: 0.50 (09:00 - 15:00)\n        - John Smith: 0.17 (15:00 - 17:00)\n- Sat, 2025-07-05 17:00+0900 - Sun, 2025-07-06 05:00+0900\n    - Weekly Rotation\n        - John Smith: 1.00 (17:00 - 05:00)\n- Sun, 2025-07-06 05:00+0900 - Sun, 2025-07-06 17:00+0900\n    - Weekly Rotation\n        - John Smith: 1.00 (05:00 - 17:00)\n- Sun, 2025-07-06 17:00+0900 - Mon, 2025-07-07 05:00+0900\n    - Weekly Rotation\n        - John Smith: 1.00 (17:00 - 05:00)\n- Mon, 2025-07-07 17:00+0900 - Tue, 2025-07-08 05:00+0900\n    - Weekly Rotation\n        - Takeshi Arabiki: 1.00 (17:00 - 05:00)\n\n# PagerDuty schedules\n\n## Weekly Rotation\n\n- 2025-07-01T05:00:00+09:00 - 2025-07-05T09:00:00+09:00: John Smith\n- 2025-07-05T09:00:00+09:00 - 2025-07-05T15:00:00+09:00: Takeshi Arabiki\n- 2025-07-05T15:00:00+09:00 - 2025-07-07T05:00:00+09:00: John Smith\n- 2025-07-07T05:00:00+09:00 - 2025-07-08T05:00:00+09:00: Takeshi Arabiki\n```\n\n## Author\n\nTakeshi Arabiki ([@abicky](https://github.com/abicky))\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabicky%2Fpd-shift","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fabicky%2Fpd-shift","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabicky%2Fpd-shift/lists"}