Skip to content

ceckles/GO-Task-Cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

28 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

GO-Task-Cli

Go Cobra

A simple and efficient command-line task management tool built with Go. Manage your tasks with full CRUD operations directly from your terminal.

πŸš€ Features

  • βœ… Add tasks - Quickly add new tasks to your list
  • πŸ“‹ List tasks - View all tasks or filter by status
  • βœ“ Complete tasks - Mark tasks as done
  • πŸ—‘οΈ Delete tasks - Remove tasks and auto-resequence IDs
  • πŸ’Ύ CSV storage - Simple file-based storage
  • ⏰ Time tracking - See when tasks were created with relative time

πŸ“‹ Table of Contents

πŸ”§ Prerequisites

  • Go 1.18+ - Download Go
  • Git - For cloning the repository

πŸ“¦ Installation

Option 1: Build from Source

  1. Clone the repository:

    git clone https://github.com/ceckles/GO-Task-Cli.git
    cd GO-Task-Cli
  2. Install dependencies:

    go mod download
  3. Build the project:

    go build -o task
  4. Install globally (optional):

    # Linux/macOS
    sudo mv task /usr/local/bin/
    
    # Or add to your PATH
    export PATH=$PATH:$(pwd)

Option 2: Run Directly

You can run the tool directly without building:

go run main.go [command]

🎯 Usage

Basic Commands

List all tasks (short view):

task list
# or
go run main.go list

List all tasks with full details:

task list -a
# or
go run main.go list -a

Add a new task:

task add "Complete the project documentation"
# or
go run main.go add "Complete the project documentation"

Mark a task as complete:

task complete 1
# or
go run main.go complete 1

Delete a task:

task delete 1
# or
go run main.go delete 1

Show help:

task --help
task [command] --help

πŸ“š Commands

list

List all tasks. By default shows a short view (ID, Task, Created time). Use the -a or --all flag to see all details including completion status.

task list          # Short view
task list -a       # Full view with all details
task list --all    # Same as -a

add

Add a new task to your list. The task will be assigned an auto-incremented ID.

task add "Your task description here"

Example:

$ task add "Review pull request #42"
Task added: Review pull request #42

complete

Mark a task as complete by providing its ID. The command will check if the task is already completed.

task complete [task-id]

Example:

$ task complete 1
Task completed successfully

delete

Delete a task by its ID. All remaining task IDs will be automatically re-sequenced.

task delete [task-id]

Example:

$ task delete 2
Task ID 2 deleted and remaining IDs re-sequenced.

πŸ› οΈ Development

Project Setup

  1. Install Go dependencies:

    go mod download
  2. Run the application:

    go run main.go
  3. Build the binary:

    go build -o task

Adding New Commands with Cobra

This project uses Cobra for CLI command management.

Install Cobra CLI (if not already installed):

go install github.com/spf13/cobra-cli@latest

Add a new command:

cobra-cli add <command-name>

Example:

cobra-cli add edit

This will create a new command file in the cmd/ directory that you can customize.

Running Tests

go test ./...

File Structure

The tasks are stored in a CSV file (tasks.csv) with the following format:

ID,Task,Created,Done
1,Example task,2024-01-15 10:30:00 -0500 EST,false

πŸ“ Project Structure

GO-Task-Cli/
β”œβ”€β”€ cmd/
β”‚   β”œβ”€β”€ root.go      # Root command and CLI setup
β”‚   β”œβ”€β”€ add.go       # Add task command
β”‚   β”œβ”€β”€ list.go      # List tasks command
β”‚   β”œβ”€β”€ complete.go  # Complete task command
β”‚   └── delete.go    # Delete task command
β”œβ”€β”€ utils/
β”‚   β”œβ”€β”€ file_utils.go  # File operations utilities
β”‚   └── time_utils.go  # Time formatting utilities
β”œβ”€β”€ main.go          # Application entry point
β”œβ”€β”€ go.mod           # Go module dependencies
β”œβ”€β”€ go.sum           # Go module checksums
β”œβ”€β”€ tasks.csv        # Task storage file (created on first use)
└── readme.md        # This file

πŸ—οΈ Tech Stack

  • Go - Programming language
  • Cobra - CLI framework for building command-line applications
  • timediff - Library for human-readable time differences

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

About

go project to create a cli tool to track tasks

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages