A CLI application for managing tasks in terminal.
$ todo-app-cli list # add, delete, update, etc$ todo-app-cli list [flags]
$ todo-app-cli add [arg] [flag]
$ todo-app-cli update [arg] [flags]
$ todo-app-cli delete [arg]
Each command supports specific flags that control how the command operates.
Add -h or --help at the end of the command to show detailed information of the command.
In order to be able to run the app using todo-app-cli command, follow these steps:
$ git clone "url_to_this_repo"
$ cd /path/to/todo-app-cli
$ go mod tidy # Checks go.mod file and download missing dependencies, or removed unneeded ones.
$ go install . # Compile and install the `todo-app-cli` binary to $GOBIN directory (or $GOPATH/bin).
$ export TODO_APP_CLI_DB_URL="your_todo_app_cli_db_url" # Replace with your actual database URL
$ export PATH=$PATH:$(go env GOBIN) # Or export PATH=$PATH:$(go env GOPATH)/bin if GOBIN is empty
$ echo 'export PATH=$PATH:$(go env GOBIN)' >> ~/.zshrc # Or ~/.bashrc, etc. to make PATH persistence
$ source ~/.zshrc # Or restart your terminalVerify the installation by running which todo-app-cli, it should show the path to the binary. Then, try running todo-app-cli list.
In order to make the TODO_APP_CLI_DB_URL environment variable persistent accross terminal sessions, you can add the export command to your shell configuration file (~/.zshrc, ~/.bashrc, etc) with this command:
$ echo 'export TODO_APP_CLI_DB_URL="your_todo_app_cli_db_url"' >> ~/.zshrc
$ source ~/.zshrcThe >> operator appends to the file. Be careful not to use > (which overwrites the file) by mistake!
Note
Create a .env file and set the TODO_APP_CLI_DB_URL value before proceeding with installation.
Running the application locally is pretty straightforward:
$ git clone "url_to_this_repo"
$ cd /path/to/todo-app-cli
$ go mod tidy # Checks go.mod file and download missing dependencies, or removed unneeded ones.
$ go run main.go list # Show list of todos in the databaseThe application uses a PostgreSQL database with the following schema:
| Column Name | Data Type | Nullable | Default | Description |
|---|---|---|---|---|
| id | int4 | NO | nextval('untitled_table_1_id_seq'::regclass) | Primary key |
| title | varchar | NO | NULL | Task title/description |
| completed | bool | NO | false | Task completion status |
| created_at | timestamptz | NO | now() | Timestamp of task creation |
| updated_at | timestamptz | NO | now() | Timestamp of last modification |
- The
idfield auto-increments using a sequence - All fields are required (non-nullable)
- New tasks are automatically marked as not completed (
completed = false) - Both
created_atandupdated_atare automatically set to the current timestamp when creating a task - The
updated_atfield should be updated whenever the task is modified
todo-app-cli/
├── .git/ # Git repository files (not detailed here)
├── cmd/ # Contains the command definitions
│ ├── add.go # Implementation for the 'add' command
│ ├── delete.go # Implementation for the 'delete' command
│ ├── list.go # Implementation for the 'list' command
│ ├── root.go # Root command and initialization logic
│ └── update.go # Implementation for the 'update' command
├── config/ # Configuration related files
│ └── config.go # Configuration loading and handling
├── internal/ # Internal packages for the application
│ └── database/ # Database interaction logic
│ └── database.go # Database operations and connection management
├── .env.example # Example environment variables file
├── .gitignore # Specifies intentionally untracked files that Git should ignore
├── go.mod # Go module definition file
├── go.sum # Checksums of Go modules for integrity
├── main.go # Entry point of the application
├── Makefile # Makefile for build and install automation
└── README.md # This file (project documentation)
-
cmd/: Contains all CLI command definitionsadd.go: Implements the 'add' commanddelete.go: Implements the 'delete' commandlist.go: Implements the 'list' commandroot.go: Contains root command and initialization logicupdate.go: Implements the 'update' command
-
config/: Contains configuration-related codeconfig.go: Handles configuration loading and management
-
internal/: Contains private application codedatabase/: Manages database interactionsdatabase.go: Implements database operations and connection handling
-
Core Files:
.env.example: Template for required environment variablesgo.mod&go.sum: Go module definition and checksumsmain.go: Application entry pointMakefile: Build and development automation