veranocli

package module
v0.0.10 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 23, 2024 License: GPL-3.0 Imports: 18 Imported by: 0

README

Verano CLI

CLI tool to manage activities in a project. This package uses under the hood the verano package to do database transactions, parse files, and sort activities.

Installation

$ go install github.com/vanillaiice/veranocli/cmd/veranocli@latest

Features

  • Sort activities in a project based on their relationships (only start to finish relationships supported for now).
  • Compute the start and finish times of all activities.
  • Render a graph (with graphviz) image file showing the activities and their relationships.
  • Parse and process lists of activities in JSON, CSV, and XLSX formats
  • Storage of the activities in a SQLite database.

Usage

NAME:
   verano cli - manage activities in a project

USAGE:
   verano cli [global options] command [command options] 

VERSION:
   v0.0.10

AUTHOR:
   Vanillaiice <vanillaiice1@proton.me>

COMMANDS:
   parse, p  parse activities in json, csv, and xlsx formats
   db, d     make database transactions
   sort, s   topologically sort activities
   help, h   Shows a list of commands or help for one command

GLOBAL OPTIONS:
   --help, -h     show help
   --version, -v  print the version

Example

Parsing a list of activities in xlsx format and generating a graph:

$ veranocli parse -f activities.xlsx -g activities.png
Id  Description   Duration  Start             Finish            Cost   
1   Tip landlord  6h0m0s    1 Jan 0001 00:00  1 Jan 0001 00:00  10000  
2   Buy eggs      20m0s     1 Jan 0001 00:00  1 Jan 0001 00:00  20     
3   Buy pan       15m0s     1 Jan 0001 00:00  1 Jan 0001 00:00  30     
4   Eat eggs      5m0s      1 Jan 0001 00:00  1 Jan 0001 00:00  0      
5   Cook eggs     10m0s     1 Jan 0001 00:00  1 Jan 0001 00:00  0      
6   Get money     36h0m0s   1 Jan 0001 00:00  1 Jan 0001 00:00  0      

activities

Sorting and updating the timeline of a list of activities in xlsx format:

$ veranocli sort -f activities.xlsx
Id  Description   Duration  Start              Finish             Cost   
6   Get money     36h0m0s   23 Mar 2024 21:23  25 Mar 2024 09:23  0      
1   Tip landlord  6h0m0s    25 Mar 2024 09:23  25 Mar 2024 15:23  10000  
2   Buy eggs      20m0s     25 Mar 2024 09:23  25 Mar 2024 09:43  20     
3   Buy pan       15m0s     25 Mar 2024 09:23  25 Mar 2024 09:38  30     
5   Cook eggs     10m0s     25 Mar 2024 09:43  25 Mar 2024 09:53  0      
4   Eat eggs      5m0s      25 Mar 2024 15:23  25 Mar 2024 15:28  0      

Author

Vanillaiice

Licence

GPLv3

Documentation

Index

Constants

View Source
const TimeFormat = "2 Jan 2006 15:04"

Time format to use when parsing

Variables

This section is empty.

Functions

func DeleteActivities

func DeleteActivities(dbPath string, id []int) (err error)

DeleteActivities deletes activities with the specified 'ids' from the database located at 'dbPath'. It returns an error if the deletion operation encounters any issues.

func DeleteActivity

func DeleteActivity(dbPath string, id int) (err error)

DeleteActivity deletes the activity with the specified 'id' from the database located at 'dbPath'. It returns an error if the deletion operation encounters any issues.

func GetActivities

func GetActivities(dbPath string, ids []int) (activities []*activity.Activity, err error)

GetActivities retrieves activities with the specified 'ids' from the database located at 'dbPath'. It returns a slice of activities and any encountered error during the operation.

func GetActivitiesAll

func GetActivitiesAll(dbPath string) (activities []*activity.Activity, err error)

GetActivitiesAll retrieves all activities from the database located at 'dbPath'. It returns a slice of activities and any encountered error during the operation.

func GetFormat

func GetFormat(file string) (format graphviz.Format, err error)

GetFormat determines the graphviz format based on the file extension. It returns the detected format and any encountered error during the process.

func InsertActivities

func InsertActivities(acts []*activity.Activity, dbPath string, duplicateInsertPolicy db.DuplicateInsertPolicy) (err error)

InsertActivities inserts the provided slice of activities 'acts' into the database located at 'dbPath'. The optional 'duplicateInsertPolicy' parameter specifies the policy for handling duplicate inserts. It returns an error if the insertion operation encounters any issues.

func InsertActivity

func InsertActivity(act *activity.Activity, dbPath string, duplicateInsertPolicy db.DuplicateInsertPolicy) (err error)

InsertActivity inserts the provided 'act' activity into the database located at 'dbPath'. The optional 'duplicateInsertPolicy' parameter specifies the policy for handling duplicate inserts. It returns an error if the insertion operation encounters any issues.

func Parse

func Parse(path string) (activities []*activity.Activity, err error)

Parse reads and interprets the content of a file specified by 'path' and returns a slice of activities. It automatically detects the file type based on its extension and uses the appropriate parser. Supported file types include SQLite database (.db), JSON (.json), CSV (.csv), and XLSX (.xlsx). It returns a slice of activities and any encountered error during the parsing process.

func PrintPretty

func PrintPretty(activities []*activity.Activity, withColor bool)

PrintPretty prints a formatted table with details of each activity in the provided slice. The 'withColor' parameter determines whether to use colored output.

func PrintRaw

func PrintRaw(activities []*activity.Activity)

PrintRaw prints the raw details of each activity in the provided slice.

func Sort

func Sort(filename, start string) (activitiesSorted []*activity.Activity, err error)

Sort reads the file specified by 'filename' and organizes the activities based on their dependencies. The 'start' parameter represents the project start date. It returns a sorted slice of activities and any encountered error during the sorting process.

func UpdateActivity

func UpdateActivity(dbPath string, id int, field, value string) (err error)

UpdateActivity updates the specified field of the activity with 'id' in the database located at 'dbPath'. The 'field' parameter specifies the field to be updated, and 'value' is the new value for that field. It returns an error if the update operation encounters any issues.

func WriteFile

func WriteFile(filename string, activities []*activity.Activity) (err error)

WriteFile writes the activities to a file with the specified 'filename'. The file format is determined based on the file extension. It returns any encountered error during the writing process.

Types

This section is empty.

Directories

Path Synopsis
cmd
veranocli command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL