setjcomment 1.1.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,11 @@
1
+ Copyright (c) 2024 Juan Jose Solorzano Carrillo
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
@@ -0,0 +1,81 @@
1
+ Metadata-Version: 2.4
2
+ Name: setjcomment
3
+ Version: 1.1.1
4
+ Summary: A Jira comment management tool via terminal. Manage your JIRA issue comments directly from the terminal, using the REST API of JIRA. This tool allows you to add comments to JIRA issues using a template file for consistent formatting, and supports multiple editors for editing the comment content.
5
+ Author-email: Juan Jose Solorzano <juanjose.solorzano.c@gmail.com>
6
+ License-File: LICENSE
7
+ Requires-Python: >=3.8
8
+ Description-Content-Type: text/markdown
9
+
10
+ # setjcomment
11
+
12
+ > A Jira comment management tool via terminal. Manage your JIRA issue comments directly from the terminal, using the REST API of JIRA. This tool allows you to add comments to JIRA issues using a template file for consistent formatting, and supports multiple editors for editing the comment content.
13
+
14
+ `setjcomment` allows you to add comments to JIRA issues directly from your terminal, using a template file for consistent formatting.
15
+
16
+ ---
17
+
18
+ ## Features
19
+
20
+ - **Add comments to JIRA issues** directly from the terminal
21
+ - **Use a template file** for consistent comment formatting
22
+ - **Supports multiple editors** (nvim, VScode, Notepad)
23
+ - **Environment variable configuration** for JIRA server, username, and password
24
+ - Works as a global CLI command after installation
25
+
26
+ ---
27
+
28
+ ## Installation
29
+
30
+ ```bash
31
+ pip install setjcomment
32
+ ```
33
+
34
+ Or install from source:
35
+
36
+ ```bash
37
+ git clone https://github.com/your-username/setjcomment.git
38
+ cd setjcomment
39
+ pip install .
40
+ ```
41
+
42
+ ---
43
+
44
+ ## Dependencies
45
+ - [`Pygments`](https://pypi.org/project/Pygments/) for syntax highlighting
46
+ - [`colored`](https://pypi.org/project/colored/) for terminal color output
47
+
48
+ ## Usage
49
+
50
+ ```bash
51
+
52
+ positional arguments:
53
+ issue_id The ID of the JIRA issue (e.g., 6552 for SETV-6552).
54
+
55
+ optional arguments:
56
+ -h, --help show this help message and exit
57
+ -s SHORT, --short SHORT
58
+ for add a short unformatted comment.
59
+ -vs, --VScode Open the template file in VScode instead of nvim.
60
+ -np, --notepad Open the template file in notepad instead of nvim.
61
+
62
+ ```
63
+
64
+ ### Examples
65
+
66
+ ```bash
67
+ setjcomment 6552 -s "This is a short comment."
68
+ setjcomment 6552 -vs # Opens the template file in VScode for editing.
69
+ setjcomment 6552 -np # Opens the template file in Notepad for editing.
70
+ ```
71
+ ---
72
+
73
+ ## License
74
+
75
+ See [LICENSE](LICENSE) for details.
76
+
77
+ ---
78
+
79
+ ## Author
80
+
81
+ **Juan Jose Solorzano Carrillo** — juanjose.solorzano.c@gmail.com
@@ -0,0 +1,72 @@
1
+ # setjcomment
2
+
3
+ > A Jira comment management tool via terminal. Manage your JIRA issue comments directly from the terminal, using the REST API of JIRA. This tool allows you to add comments to JIRA issues using a template file for consistent formatting, and supports multiple editors for editing the comment content.
4
+
5
+ `setjcomment` allows you to add comments to JIRA issues directly from your terminal, using a template file for consistent formatting.
6
+
7
+ ---
8
+
9
+ ## Features
10
+
11
+ - **Add comments to JIRA issues** directly from the terminal
12
+ - **Use a template file** for consistent comment formatting
13
+ - **Supports multiple editors** (nvim, VScode, Notepad)
14
+ - **Environment variable configuration** for JIRA server, username, and password
15
+ - Works as a global CLI command after installation
16
+
17
+ ---
18
+
19
+ ## Installation
20
+
21
+ ```bash
22
+ pip install setjcomment
23
+ ```
24
+
25
+ Or install from source:
26
+
27
+ ```bash
28
+ git clone https://github.com/your-username/setjcomment.git
29
+ cd setjcomment
30
+ pip install .
31
+ ```
32
+
33
+ ---
34
+
35
+ ## Dependencies
36
+ - [`Pygments`](https://pypi.org/project/Pygments/) for syntax highlighting
37
+ - [`colored`](https://pypi.org/project/colored/) for terminal color output
38
+
39
+ ## Usage
40
+
41
+ ```bash
42
+
43
+ positional arguments:
44
+ issue_id The ID of the JIRA issue (e.g., 6552 for SETV-6552).
45
+
46
+ optional arguments:
47
+ -h, --help show this help message and exit
48
+ -s SHORT, --short SHORT
49
+ for add a short unformatted comment.
50
+ -vs, --VScode Open the template file in VScode instead of nvim.
51
+ -np, --notepad Open the template file in notepad instead of nvim.
52
+
53
+ ```
54
+
55
+ ### Examples
56
+
57
+ ```bash
58
+ setjcomment 6552 -s "This is a short comment."
59
+ setjcomment 6552 -vs # Opens the template file in VScode for editing.
60
+ setjcomment 6552 -np # Opens the template file in Notepad for editing.
61
+ ```
62
+ ---
63
+
64
+ ## License
65
+
66
+ See [LICENSE](LICENSE) for details.
67
+
68
+ ---
69
+
70
+ ## Author
71
+
72
+ **Juan Jose Solorzano Carrillo** — juanjose.solorzano.c@gmail.com
@@ -0,0 +1,27 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "setjcomment"
7
+ version = "1.1.1"
8
+ authors = [
9
+ { name="Juan Jose Solorzano", email="juanjose.solorzano.c@gmail.com" }
10
+ ]
11
+ description = "A Jira comment management tool via terminal. Manage your JIRA issue comments directly from the terminal, using the REST API of JIRA. This tool allows you to add comments to JIRA issues using a template file for consistent formatting, and supports multiple editors for editing the comment content."
12
+ readme = "README.md"
13
+ requires-python = ">=3.8"
14
+ dependencies = [
15
+ ]
16
+
17
+ # Right side: package_folder.module_file:function_name
18
+ [project.scripts]
19
+ setjcomment = "setjcomment.setjcomment:run" # Creates the global 'setjcomment' terminal command!
20
+
21
+ # Tells hatchling explicitly to look for your renamed directory inside src/
22
+ [tool.hatch.build.targets.wheel]
23
+ packages = ["src/setjcomment"]
24
+
25
+ #i This section is for setuptools, which hatchling can also use. It specifies that any file matching *.txt in the mypackage directory should be included in the package data when building the wheel.
26
+ [tool.setuptools.package-data]
27
+ setjcomment = ["*.txt", "src/setjcomment/*.txt"]
@@ -0,0 +1 @@
1
+ from .setjcomment import run
@@ -0,0 +1,83 @@
1
+ import requests
2
+ import os
3
+ import subprocess
4
+ import argparse
5
+ import sys
6
+ sys.stdout.reconfigure(encoding="utf-8")#type: ignore
7
+ sys.stderr.reconfigure(encoding="utf-8")#type: ignore
8
+ from requests.auth import HTTPBasicAuth
9
+ from datetime import date
10
+ from importlib import resources
11
+
12
+ JIRA_SERVER = os.getenv("JIRA_SERVER","")
13
+ USERNAME = os.getenv("JIRA_USERNAME","")
14
+ PASSWORD = os.getenv("JIRA_PASSWORD","")
15
+ TEMP_PATH = os.getenv("TEMP", "D:\\temp")
16
+ TRACKING_TITLE = "PERSONAL TRACKING"
17
+ TEMPLATE_FILE_NAME = "temp_comment.jira"
18
+ TODAY = date.today().strftime("%d/%m/%Y")
19
+ ISSUE_KEY = "SETV-%s"
20
+ EDITOR = "nvim"
21
+ URL = "https://{0}/rest/api/2/issue/{1}/comment"
22
+ HEADERS = {"Accept": "application/json","Content-Type": "application/json"}
23
+ PAYLOAD = {"body": ""}
24
+
25
+ def parse_args():
26
+ parser = argparse.ArgumentParser(description="Add a comment to a JIRA issue.")
27
+ parser.add_argument("issue_id", type=int, help="The ID of the JIRA issue (e.g., 6552 for SETV-6552).")
28
+ parser.add_argument("-s", "--short",required=False, default="", type=str, help="for add a short unformatted comment.")
29
+ parser.add_argument("-vs", "--VScode",action="store_true", default=False, help="Open the template file in VScode instead of nvim.")
30
+ parser.add_argument("-np", "--notepad", action="store_true", default=False, help="Open the template file in notepad instead of nvim.")
31
+ return parser.parse_args()
32
+
33
+ def create_payload(cwd: str, args:argparse.Namespace) -> dict[str, str]:
34
+ body = ""
35
+ with open(f"{cwd}\\{TEMPLATE_FILE_NAME}", "r") as f:
36
+ lines = f.readlines()
37
+ with open(f"{TEMP_PATH}\\{TEMPLATE_FILE_NAME}", "w") as outputfile:
38
+ outputfile.writelines(lines)
39
+ if args.short:
40
+ body = str(args.short).replace(";", "\n")
41
+ else:
42
+ if args.VScode:
43
+ proc = subprocess.Popen(["c:\\LegacyApp\\VScode\\Code.exe", f"{TEMP_PATH}\\{TEMPLATE_FILE_NAME}"], shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
44
+ proc.wait()
45
+ elif args.notepad:
46
+ subprocess.call(["notepad", f"{TEMP_PATH}\\{TEMPLATE_FILE_NAME}"])
47
+ else:
48
+ subprocess.call([EDITOR, f"{TEMP_PATH}\\{TEMPLATE_FILE_NAME}"])
49
+ with open(f"{TEMP_PATH}\\{TEMPLATE_FILE_NAME}", "r") as f:
50
+ additional_comment = f.read()
51
+ os.remove(f"{TEMP_PATH}\\{TEMPLATE_FILE_NAME}")
52
+ for line in additional_comment.splitlines():
53
+ if line.__contains__("::DATE::"):
54
+ line = line.replace("::DATE::", TODAY)
55
+ if line.__contains__("----"):
56
+ line = line+"\n"
57
+ body += line + "\n"
58
+ return {"body": body}
59
+
60
+ def connect_jira(payload: dict[str,str], args: argparse.Namespace):
61
+ url = URL.format(JIRA_SERVER, ISSUE_KEY % args.issue_id)
62
+ auth = HTTPBasicAuth(USERNAME, PASSWORD)
63
+ response = requests.post(url, auth=auth, headers=HEADERS, json=payload)
64
+ if response.status_code == 201:
65
+ print("Comment added successfully.")
66
+ else:
67
+ print("Failed to add comment. Status code:", response.status_code)
68
+ print("Response:", response.text)
69
+
70
+ def run() -> None:
71
+ text_path = resources.files("setjcomment").joinpath(TEMPLATE_FILE_NAME)
72
+ if not text_path.is_file():
73
+ print(f"Template file '{TEMPLATE_FILE_NAME}' not found in the package resources.")
74
+ return
75
+ path = str(text_path.parent)#type: ignore
76
+ args = parse_args()
77
+ print(f"Using template file at: {str(path)}")
78
+ payload = create_payload(str(path), args)
79
+ connect_jira(payload, args)
80
+
81
+ #This allows the script to be run directly, and also allows the 'run' function to be imported and used in other contexts (like testing).
82
+ if __name__ == "__main__":
83
+ run()
@@ -0,0 +1,13 @@
1
+ h1. ::DATE::
2
+ * Task1 - *0.0h*
3
+
4
+
5
+ ----
6
+
7
+ h1. Personal Tracking:
8
+
9
+ {quote}
10
+ TEXT
11
+ - Topic1: text
12
+ - Topic2: text
13
+ {quote}