Skip to content

Instantly share code, notes, and snippets.

@robkorv
Last active December 24, 2020 10:22
Show Gist options
  • Select an option

  • Save robkorv/ebee55b6a8d0d41236b51e2c9e53d3f2 to your computer and use it in GitHub Desktop.

Select an option

Save robkorv/ebee55b6a8d0d41236b51e2c9e53d3f2 to your computer and use it in GitHub Desktop.
issue_slug
#!/usr/bin/env python3
import shlex
import subprocess
import sys
import click
import slugify
@click.command()
@click.argument("issue", type=int)
def main(issue):
cmd = shlex.split('hub issue show -f "%I-%t" {}'.format(issue))
result = subprocess.run(cmd, universal_newlines=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
if result.returncode == 0:
print(slugify.slugify_url(result.stdout))
else:
sys.exit(result.stdout.strip())
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment