This CLI tool helps manage billing entries and retrieve project positions from the Troi service. Below are the available commands and their usage:
Ensure you have Python 3.x installed. Install necessary packages:
pip install click click-completion PyYAML pandas
Create a config.yaml
file in the same directory as your script with the following content:
credentials:
url: "https://api.troi.example.com"
username: "your_username"
api_token: "your_api_token"
task_id: 123 # default value (optional)
user_id: 456 # default value (optional)
client_id: 3 # default value (optional)
Retrieve all project positions:
./troi_cli.py all_positions
Retrieve billing hours for a specific project and date range:
./troi_cli.py billing_hours <project_id> [<date_from>]
[--date_to <date_to>]
[--client_id <client_id>]
[--user_id <user_id>]
[--position_id <position_id>]
<project_id>
: ID of the project (required).<date_from>
: Start date for billing hours inYYYY-MM-DD
format (optional, default is today's date).
--date_to
: End date for billing hours inYYYY-MM-DD
format (optional).--client_id
: ID of the client (optional, default is3
).--user_id
: ID of the user (optional).--position_id
: ID of the position (optional).
Update a billing entry:
./troi_cli.py update_entry <record_id> <hours> <tags>...
[-d <date_from>]
[-t <task_id>]
[-u <user_id>]
[-c <client_id>]
[-m <remark>]
<record_id>
: ID of the record to update (required).<hours>
: Number of hours billed (required).<tags>
: List of tags associated with the entry (required).
-d, --date_from
: Start date for billing hours inYYYY-MM-DD
format (optional, default is today's date).-t, --task_id
: ID of the task (optional, will use default value fromconfig.yaml
if not provided).-u, --user_id
: ID of the user (optional, will use default value fromconfig.yaml
if not provided).-c, --client_id
: ID of the client (optional, default is3
).-m, --remark
: Annotation remark (optional).
# Get all positions
./troi_cli.py all_positions
# Get billing hours
./troi_cli.py billing_hours 101 --date_from 2023-01-01 --date_to 2023-01-31
# Update a billing entry
./troi_cli.py update_entry 1 3.5 development -d 2023-01-01 -t 1001 -u 2002 -c 3001 -m "Finished development task"
This project is licensed under the MIT License - see the LICENSE file for details.