scwrypts/py/linear/comment.py
yage 7617c938b1 v2.8.0
=====================================================================

--- Changes ------------------------------

- python library functions moved to `py/lib`
- python scwrypts renamed in kebob-case to help prevent import
- __name__ == '__main__' enforced on all python scwrypts

--- New Features -------------------------

- `__override` variables now allow values to be force-overwritten
- py.lib.http.client provides a slim `requests.request` wrapper

--- New Scripts --------------------------

py/data/convert )
  quick data converters
   - csv-to-json
   - csv-to-yaml
   - json-to-csv
   - json-to-yaml
   - yaml-to-csv
   - yaml-to-json

py/linear )
  uses the linear.app graphql API for PM tasks
   - comment

--- Bug Fixes ----------------------------

- `scwrypts` handles arguments with quotes and special characters
2023-02-13 21:57:17 -07:00

48 lines
1.0 KiB
Python
Executable File

#!/usr/bin/env python
from argparse import ArgumentParser
from py.lib.data.io import get_stream, add_io_arguments
from py.lib.linear import graphql
if __name__ != '__main__':
raise Exception('executable only; must run through scwrypts')
parser = ArgumentParser(description = 'comment on an issue in linear.app')
parser.add_argument(
'-i', '--issue',
dest = 'issue_id',
help = 'issue short-code (e.g. CLOUD-319)',
required = True,
)
parser.add_argument(
'-m', '--message',
dest = 'message',
help = 'comment to post to the target issue',
required = True,
)
add_io_arguments(parser, toggle_input=False)
args = parser.parse_args()
query = f'''
mutation CommentCreate {{
commentCreate(
input: {{
issueId: "{args.issue_id}"
body: """from wrobot:
```
{args.message.strip()}
```"""
}}
) {{ success }}
}}
'''
response = graphql(query)
with get_stream(args.output_file, 'w+') as output:
output.write(response.text)