setjtime 1.2.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.
- setjtime-1.2.1/LICENSE +11 -0
- setjtime-1.2.1/PKG-INFO +77 -0
- setjtime-1.2.1/README.md +68 -0
- setjtime-1.2.1/pyproject.toml +23 -0
- setjtime-1.2.1/src/setjtime/__init__.py +1 -0
- setjtime-1.2.1/src/setjtime/setjtime.py +49 -0
setjtime-1.2.1/LICENSE
ADDED
|
@@ -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.
|
setjtime-1.2.1/PKG-INFO
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: setjtime
|
|
3
|
+
Version: 1.2.1
|
|
4
|
+
Summary: A tool to log time to JIRA issues directly from the terminal.
|
|
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
|
+
# setjtime
|
|
11
|
+
|
|
12
|
+
> A Jira time logger tool via terminal.
|
|
13
|
+
|
|
14
|
+
`setjtime` allows you to log time to JIRA issues directly from your terminal. It supports adding simple comments so you can provide context for the time logged. This tool uses the REST API of JIRA to interact with your JIRA server, and requires environment variables for configuration.
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## Features
|
|
18
|
+
|
|
19
|
+
- **Log time to JIRA issues** directly from the terminal
|
|
20
|
+
- **Add comments to JIRA issues** for context
|
|
21
|
+
- **Environment variable configuration** for JIRA server, username, and password
|
|
22
|
+
- **Works as** a global CLI command after installation
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## Installation
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
pip install setjcomment
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Or install from source:
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
git clone https://github.com/JuanJoseSolorzano/setjtime_project.git
|
|
36
|
+
cd setjtime_project
|
|
37
|
+
pip install .
|
|
38
|
+
```
|
|
39
|
+
## Required Environment Variables
|
|
40
|
+
- `JIRA_SERVER`: The URL of your JIRA server (e.g., `yourdomain.atlassian.net`).
|
|
41
|
+
- `JIRA_USERNAME`: Your JIRA username (usually your email address).
|
|
42
|
+
- `JIRA_PASSWORD`: Your JIRA API token or password.
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
## Usage
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
|
|
49
|
+
positional arguments:
|
|
50
|
+
issue_id The ID of the JIRA issue (e.g., 6552 for SETV-6552).
|
|
51
|
+
|
|
52
|
+
optional arguments:
|
|
53
|
+
-h, --help show this help message and exit
|
|
54
|
+
|
|
55
|
+
-t TIME, --time TIME : Time spent (e.g., "2h", "30m").
|
|
56
|
+
-c COMMENT, --comment COMMENT : Add a short unformatted comment [optional].
|
|
57
|
+
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### Examples
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
setjcomment 6552 -s "This is a short comment."
|
|
64
|
+
setjcomment 6552 -t "2h" # Logs 2 hours to the JIRA issue.
|
|
65
|
+
setjcomment 6552 -c "This is a short comment." # Adds a short comment to the JIRA issue.
|
|
66
|
+
```
|
|
67
|
+
---
|
|
68
|
+
|
|
69
|
+
## License
|
|
70
|
+
|
|
71
|
+
See [LICENSE](LICENSE) for details.
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
## Author
|
|
76
|
+
|
|
77
|
+
**Juan Jose Solorzano Carrillo** — juanjose.solorzano.c@gmail.com
|
setjtime-1.2.1/README.md
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# setjtime
|
|
2
|
+
|
|
3
|
+
> A Jira time logger tool via terminal.
|
|
4
|
+
|
|
5
|
+
`setjtime` allows you to log time to JIRA issues directly from your terminal. It supports adding simple comments so you can provide context for the time logged. This tool uses the REST API of JIRA to interact with your JIRA server, and requires environment variables for configuration.
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Features
|
|
9
|
+
|
|
10
|
+
- **Log time to JIRA issues** directly from the terminal
|
|
11
|
+
- **Add comments to JIRA issues** for context
|
|
12
|
+
- **Environment variable configuration** for JIRA server, username, and password
|
|
13
|
+
- **Works as** a global CLI command after installation
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
pip install setjcomment
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Or install from source:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
git clone https://github.com/JuanJoseSolorzano/setjtime_project.git
|
|
27
|
+
cd setjtime_project
|
|
28
|
+
pip install .
|
|
29
|
+
```
|
|
30
|
+
## Required Environment Variables
|
|
31
|
+
- `JIRA_SERVER`: The URL of your JIRA server (e.g., `yourdomain.atlassian.net`).
|
|
32
|
+
- `JIRA_USERNAME`: Your JIRA username (usually your email address).
|
|
33
|
+
- `JIRA_PASSWORD`: Your JIRA API token or password.
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## Usage
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
|
|
40
|
+
positional arguments:
|
|
41
|
+
issue_id The ID of the JIRA issue (e.g., 6552 for SETV-6552).
|
|
42
|
+
|
|
43
|
+
optional arguments:
|
|
44
|
+
-h, --help show this help message and exit
|
|
45
|
+
|
|
46
|
+
-t TIME, --time TIME : Time spent (e.g., "2h", "30m").
|
|
47
|
+
-c COMMENT, --comment COMMENT : Add a short unformatted comment [optional].
|
|
48
|
+
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### Examples
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
setjcomment 6552 -s "This is a short comment."
|
|
55
|
+
setjcomment 6552 -t "2h" # Logs 2 hours to the JIRA issue.
|
|
56
|
+
setjcomment 6552 -c "This is a short comment." # Adds a short comment to the JIRA issue.
|
|
57
|
+
```
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
## License
|
|
61
|
+
|
|
62
|
+
See [LICENSE](LICENSE) for details.
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
## Author
|
|
67
|
+
|
|
68
|
+
**Juan Jose Solorzano Carrillo** — juanjose.solorzano.c@gmail.com
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "setjtime"
|
|
7
|
+
version = "1.2.1"
|
|
8
|
+
authors = [
|
|
9
|
+
{ name="Juan Jose Solorzano", email="juanjose.solorzano.c@gmail.com" }
|
|
10
|
+
]
|
|
11
|
+
description = "A tool to log time to JIRA issues directly from the terminal."
|
|
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
|
+
setjtime = "setjtime.setjtime:run" # Creates the global 'setjtime' terminal command!
|
|
20
|
+
|
|
21
|
+
# Tells hatchling explicitly to look for your renamed directory inside src/
|
|
22
|
+
[tool.hatch.build.targets.wheel]
|
|
23
|
+
packages = ["src/setjtime"]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from .setjtime import run
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import requests
|
|
2
|
+
import os
|
|
3
|
+
import argparse
|
|
4
|
+
from requests.auth import HTTPBasicAuth
|
|
5
|
+
from datetime import date
|
|
6
|
+
import sys
|
|
7
|
+
sys.stdout.reconfigure(encoding="utf-8")#type: ignore
|
|
8
|
+
sys.stderr.reconfigure(encoding="utf-8")#type: ignore
|
|
9
|
+
|
|
10
|
+
JIRA_SERVER = os.getenv("JIRA_SERVER","")
|
|
11
|
+
USERNAME = os.getenv("JIRA_USERNAME","")
|
|
12
|
+
PASSWORD = os.getenv("JIRA_PASSWORD","")
|
|
13
|
+
TODAY = date.today().strftime("%d/%m/%Y")
|
|
14
|
+
ISSUE_KEY = "SETV-%s"
|
|
15
|
+
URL = "https://{0}/rest/api/2/issue/{1}/comment"
|
|
16
|
+
HEADERS = {"Accept": "application/json","Content-Type": "application/json"}
|
|
17
|
+
PAYLOAD = {"body": ""}
|
|
18
|
+
|
|
19
|
+
def parse_args():
|
|
20
|
+
parser = argparse.ArgumentParser(description="Add a comment to a JIRA issue.")
|
|
21
|
+
parser.add_argument("issue_id", type=int, help="The ID of the JIRA issue (e.g., 6552 for SETV-6552).")
|
|
22
|
+
parser.add_argument("-t", "--time",type=str,required=True, default="0h", help="Time spent to log, e.g., 1h, 30m, 2d, etc.")
|
|
23
|
+
parser.add_argument("-c", "--comment",type=str,required=False, default="", help="for add a short unformatted comment.")
|
|
24
|
+
return parser.parse_args()
|
|
25
|
+
|
|
26
|
+
def create_payload(args:argparse.Namespace) -> dict[str, str]:
|
|
27
|
+
body = ""
|
|
28
|
+
spent_time = args.time
|
|
29
|
+
if args.comment:
|
|
30
|
+
body = str(args.comment).replace(";", "\n")
|
|
31
|
+
return {"timeSpent": spent_time,"comment": f" [{spent_time}] - {body} Logged on *{TODAY}*"}
|
|
32
|
+
|
|
33
|
+
def connect_jira(payload: dict[str,str],issue_id:str):
|
|
34
|
+
url = f"https://{JIRA_SERVER}/rest/api/2/issue/{ISSUE_KEY % issue_id}/worklog"
|
|
35
|
+
auth = HTTPBasicAuth(USERNAME, PASSWORD)
|
|
36
|
+
response = requests.post(url, auth=auth, headers=HEADERS, json=payload)
|
|
37
|
+
if response.status_code == 201:
|
|
38
|
+
print("Worklog entry added successfully.")
|
|
39
|
+
else:
|
|
40
|
+
print("Failed to add worklog entry. Status code:", response.status_code)
|
|
41
|
+
print(response.text)
|
|
42
|
+
|
|
43
|
+
def run():
|
|
44
|
+
args = parse_args()
|
|
45
|
+
payload = create_payload(args)
|
|
46
|
+
connect_jira(payload,args.issue_id)
|
|
47
|
+
|
|
48
|
+
if __name__ == "__main__":
|
|
49
|
+
run()
|