task_tracker_cli 0.1.1

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: b33d5a33b59a52885416ce62c9fe22c5085bbec03b019cb21c4437233d49b51b
4
+ data.tar.gz: aeab96ce6b637caf26b9dfa457c78df0f9bd435f778cc61d015e417d3cee0070
5
+ SHA512:
6
+ metadata.gz: 913767bee758adc5c1d7c6d9eef64ee58d23c23ca97f78ef7b0e86895982622cc89fa3e62df230d5b2f8de56225abeb18ba86b695531863d86652cb2a13b7315
7
+ data.tar.gz: 136cd645c21585c2e86767bf6fea756edb46d0f2f496a194571631595d6b1c9a6d9db2fff1f91a0444e5fb422f35cbd621523f23886523ba6827e45ca00e163b
data/README.md ADDED
@@ -0,0 +1,160 @@
1
+ # Task Tracker CLI
2
+
3
+ Built by [Sulman Baig](https://www.sulmanweb.com)
4
+
5
+ > This project requirements are from [Task Tracker Roadmap.sh](https://roadmap.sh/projects/task-tracker)
6
+
7
+ Task Tracker CLI is a Ruby gem that provides a command-line interface for managing your tasks and to-do list. It allows you to easily add, update, delete, and track the status of your tasks directly from the terminal.
8
+
9
+ ## Features
10
+
11
+ - Add new tasks
12
+ - Update existing tasks
13
+ - Delete tasks
14
+ - Mark tasks as in-progress or done
15
+ - List all tasks
16
+ - List tasks by status (todo, in-progress, done)
17
+ - Persistent storage using JSON file in home directory
18
+
19
+ ## Requirements
20
+
21
+ - Ruby version: 2.5.0 or higher
22
+
23
+ ## Installation
24
+
25
+ Ensure you have Ruby 2.5.0 or higher installed. You can check your Ruby version by running:
26
+
27
+ ```
28
+ ruby --version
29
+ ```
30
+
31
+ If you need to install or update Ruby, visit the [official Ruby website](https://www.ruby-lang.org/en/documentation/installation/) for instructions.
32
+
33
+ Install the gem by running:
34
+
35
+ ```
36
+ gem install task_tracker_cli
37
+ ```
38
+
39
+ ## Usage
40
+
41
+ After installation, you can use the `task-cli` command in your terminal to manage your tasks:
42
+
43
+ ### Adding a new task
44
+
45
+ ```
46
+ task-cli add "Task description"
47
+ ```
48
+
49
+ ### Updating a task
50
+
51
+ ```
52
+ task-cli update 1 "Updated task description"
53
+ ```
54
+
55
+ ### Deleting a task
56
+
57
+ ```
58
+ task-cli delete 1
59
+ ```
60
+
61
+ ### Marking a task as in-progress
62
+
63
+ ```
64
+ task-cli in-progress 1
65
+ ```
66
+
67
+ ### Marking a task as done
68
+
69
+ ```
70
+ task-cli done 1
71
+ ```
72
+
73
+ ### Listing all tasks
74
+
75
+ ```
76
+ task-cli list
77
+ ```
78
+
79
+ ### Listing tasks by status
80
+
81
+
82
+ ```
83
+ task-cli list todo
84
+ ```
85
+
86
+ ```
87
+ task-cli list in-progress
88
+ ```
89
+
90
+ ```
91
+ task-cli list done
92
+ ```
93
+
94
+ ## Uninstallation
95
+
96
+ To uninstall the gem, run:
97
+
98
+ ```
99
+ gem uninstall task_tracker_cli
100
+ ```
101
+
102
+ ## Task Properties
103
+
104
+ Each task has the following properties:
105
+
106
+ - `id`: A unique identifier for the task
107
+ - `description`: A short description of the task
108
+ - `status`: The status of the task (`todo`, `in-progress`, `done`)
109
+ - `createdAt`: The date and time when the task was created
110
+ - `updatedAt`: The date and time when the task was last updated
111
+
112
+ ## File Storage
113
+
114
+ Tasks are stored in a JSON file (`tasks.json`) in your home directory. This file is automatically created if it doesn't exist.
115
+
116
+ ## Development
117
+
118
+ After cloning the repository, follow these steps to set up the development environment:
119
+
120
+ 1. Install dependencies:
121
+ ```
122
+ bundle install
123
+ ```
124
+
125
+ 2. Run the tests:
126
+ ```
127
+ rspec
128
+ ```
129
+
130
+ 3. To install this gem onto your local machine, run:
131
+ ```
132
+ gem build task_tracker_cli.gemspec
133
+ gem install ./task_tracker_cli-0.1.0.gem
134
+ ```
135
+
136
+ 4. To release a new version, update the version number in `task_tracker_cli.gemspec`, and then run:
137
+ ```
138
+ gem build task_tracker_cli.gemspec
139
+ gem push task_tracker_cli-0.1.0.gem
140
+ ```
141
+
142
+ For development, you can use `irb` or `pry` to experiment with the code:
143
+
144
+ ```ruby
145
+ require 'task_tracker_cli'
146
+ task_manager = TaskManager.new
147
+ # Now you can experiment with task_manager methods
148
+ ```
149
+
150
+ ## Contributing
151
+
152
+ Bug reports and pull requests are welcome on GitHub at https://github.com/sulmanweb/task_tracker_cli. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/sulmanweb/task_tracker_cli/blob/main/CODE_OF_CONDUCT.md).
153
+
154
+ ## License
155
+
156
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
157
+
158
+ ## Code of Conduct
159
+
160
+ Everyone interacting in the Task Tracker CLI project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/sulmanweb/task_tracker_cli/blob/main/CODE_OF_CONDUCT.md).
data/bin/task-cli ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require_relative '../lib/task_tracker_cli'
3
+
4
+ TaskCLI.run
@@ -0,0 +1,146 @@
1
+ # Task Tracker in Ruby
2
+ require 'json'
3
+ require 'time'
4
+
5
+ # Define a Task class to represent each task
6
+ class Task
7
+ attr_accessor :id, :description, :status, :created_at, :updated_at
8
+
9
+ def initialize(description, status = 'todo')
10
+ @id = nil
11
+ @description = description
12
+ @status = status
13
+ @created_at = Time.now
14
+ @updated_at = Time.now
15
+ end
16
+
17
+ def update(description, status)
18
+ @description = description
19
+ @status = status
20
+ @updated_at = Time.now
21
+ end
22
+
23
+ def to_h
24
+ {
25
+ id: @id,
26
+ description: @description,
27
+ status: @status,
28
+ created_at: @created_at.to_s,
29
+ updated_at: @updated_at.to_s
30
+ }
31
+ end
32
+
33
+ def to_s
34
+ "ID: #{@id} | Description: #{@description} | Status: #{@status} | Created At: #{@created_at} | Updated At: #{@updated_at}"
35
+ end
36
+ end
37
+
38
+ # TaskManager to manage tasks
39
+ class TaskManager
40
+ TASKS_FILE = File.join(Dir.home, 'tasks.json')
41
+
42
+ def initialize
43
+ @tasks = load_tasks
44
+ end
45
+
46
+ def load_tasks
47
+ return [] unless File.exist?(TASKS_FILE)
48
+
49
+ file = File.read(TASKS_FILE)
50
+ data = JSON.parse(file, symbolize_names: true)
51
+ data.map do |task_data|
52
+ task = Task.new(task_data[:description], task_data[:status])
53
+ task.id = task_data[:id]
54
+ task.created_at = Time.parse(task_data[:created_at])
55
+ task.updated_at = Time.parse(task_data[:updated_at])
56
+ task
57
+ end
58
+ end
59
+
60
+ def save_tasks
61
+ File.open(TASKS_FILE, 'w') do |file|
62
+ file.write(JSON.pretty_generate(@tasks.map(&:to_h)))
63
+ end
64
+ end
65
+
66
+ # Create a new task
67
+ def create_task(description)
68
+ task = Task.new(description)
69
+ task.id = @tasks.empty? ? 1 : @tasks.last.id + 1
70
+ @tasks << task
71
+ save_tasks
72
+ puts "Task added successfully (ID: #{task.id})"
73
+ end
74
+
75
+ # List all tasks
76
+ def list_tasks
77
+ if @tasks.empty?
78
+ puts "No tasks found.\n"
79
+ else
80
+ @tasks.each { |task| puts task }
81
+ end
82
+ end
83
+
84
+ # List tasks by status
85
+ def list_tasks_by_status(status)
86
+ filtered_tasks = @tasks.select { |task| task.status == status }
87
+ if filtered_tasks.empty?
88
+ puts "No tasks found with status '#{status}'."
89
+ else
90
+ filtered_tasks.each { |task| puts task }
91
+ end
92
+ end
93
+
94
+ # Find a task by ID
95
+ def find_task(id)
96
+ @tasks.find { |task| task.id == id }
97
+ end
98
+
99
+ # Update a task
100
+ def update_task(id, new_description)
101
+ task = find_task(id)
102
+ if task
103
+ task.update(new_description, task.status)
104
+ save_tasks
105
+ puts "Task updated successfully!"
106
+ else
107
+ puts "Task not found."
108
+ end
109
+ end
110
+
111
+ # Delete a task
112
+ def delete_task(id)
113
+ task = find_task(id)
114
+ if task
115
+ @tasks.delete(task)
116
+ save_tasks
117
+ puts "Task deleted successfully!"
118
+ else
119
+ puts "Task not found."
120
+ end
121
+ end
122
+
123
+ # Mark a task as in progress
124
+ def mark_in_progress(id)
125
+ task = find_task(id)
126
+ if task
127
+ task.update(task.description, 'in-progress')
128
+ save_tasks
129
+ puts "Task marked as in-progress!"
130
+ else
131
+ puts "Task not found."
132
+ end
133
+ end
134
+
135
+ # Mark a task as done
136
+ def mark_done(id)
137
+ task = find_task(id)
138
+ if task
139
+ task.update(task.description, 'done')
140
+ save_tasks
141
+ puts "Task marked as done!"
142
+ else
143
+ puts "Task not found."
144
+ end
145
+ end
146
+ end
@@ -0,0 +1,57 @@
1
+ require_relative "task_manager"
2
+
3
+ class TaskCLI
4
+ def self.run
5
+ task_manager = TaskManager.new
6
+ command = ARGV[0]
7
+ args = ARGV[1..-1]
8
+
9
+ case command
10
+ when 'add'
11
+ description = args.join(' ')
12
+ task_manager.create_task(description)
13
+ when 'update'
14
+ id = args[0].to_i
15
+ new_description = args[1..-1].join(' ')
16
+ task_manager.update_task(id, new_description)
17
+ when 'delete'
18
+ id = args[0].to_i
19
+ task_manager.delete_task(id)
20
+ when 'mark-in-progress'
21
+ id = args[0].to_i
22
+ task_manager.mark_in_progress(id)
23
+ when 'mark-done'
24
+ id = args[0].to_i
25
+ task_manager.mark_done(id)
26
+ when 'list'
27
+ if args.empty?
28
+ task_manager.list_tasks
29
+ else
30
+ status = args[0]
31
+ task_manager.list_tasks_by_status(status)
32
+ end
33
+ when 'init'
34
+ self.init_project
35
+ else
36
+ puts "Invalid command. Available commands: add, update, delete, mark-in-progress, mark-done, list, init"
37
+ end
38
+ end
39
+
40
+ def self.init_project
41
+ directories = ["tasks", "config", "logs"]
42
+ files = {
43
+ "config/settings.json" => '{"setting": "default"}',
44
+ "README.md" => "# Task Tracker CLI Project\n\nThis is your task tracker project. Modify this README accordingly."
45
+ }
46
+
47
+ directories.each do |dir|
48
+ Dir.mkdir(dir) unless Dir.exist?(dir)
49
+ puts "Created directory: #{dir}"
50
+ end
51
+
52
+ files.each do |file, content|
53
+ File.open(file, 'w') { |f| f.write(content) }
54
+ puts "Created file: #{file}"
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,27 @@
1
+ Gem::Specification.new do |spec|
2
+ spec.name = "task_tracker_cli"
3
+ spec.version = "0.1.1"
4
+ spec.authors = ["Sulman Baig"]
5
+ spec.email = ["sulmanweb@gmail.com"]
6
+
7
+ spec.summary = "A CLI tool for tracking tasks."
8
+ spec.description = "A command-line interface tool to add, update, and manage tasks."
9
+ spec.homepage = "https://github.com/sulmanweb/task_tracker_cli"
10
+ spec.license = "MIT"
11
+
12
+ spec.files = Dir["lib/**/*.rb"] + Dir["bin/*"] + ["task_tracker_cli.gemspec", "README.md"]
13
+ spec.bindir = "bin"
14
+ spec.executables = ["task-cli"]
15
+ spec.require_paths = ["lib"]
16
+
17
+ spec.metadata["homepage_uri"] = spec.homepage
18
+ spec.metadata["source_code_uri"] = "https://github.com/sulmanweb/task_tracker_cli/blob/main/lib/task_tracker_cli.rb"
19
+ spec.extra_rdoc_files = %w[README.md]
20
+ spec.metadata["rubygems_mfa_required"] = "true"
21
+
22
+ spec.add_runtime_dependency 'json', '~> 2.0'
23
+ spec.required_ruby_version = '>= 2.5.0'
24
+ spec.add_development_dependency 'rspec', '~> 3.0'
25
+
26
+ spec.post_install_message = "Thank you for installing Task Tracker CLI by Sulman Baig!"
27
+ end
metadata ADDED
@@ -0,0 +1,81 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: task_tracker_cli
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Sulman Baig
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2024-10-18 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: json
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '3.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '3.0'
41
+ description: A command-line interface tool to add, update, and manage tasks.
42
+ email:
43
+ - sulmanweb@gmail.com
44
+ executables:
45
+ - task-cli
46
+ extensions: []
47
+ extra_rdoc_files:
48
+ - README.md
49
+ files:
50
+ - README.md
51
+ - bin/task-cli
52
+ - lib/task_manager.rb
53
+ - lib/task_tracker_cli.rb
54
+ - task_tracker_cli.gemspec
55
+ homepage: https://github.com/sulmanweb/task_tracker_cli
56
+ licenses:
57
+ - MIT
58
+ metadata:
59
+ homepage_uri: https://github.com/sulmanweb/task_tracker_cli
60
+ source_code_uri: https://github.com/sulmanweb/task_tracker_cli/blob/main/lib/task_tracker_cli.rb
61
+ rubygems_mfa_required: 'true'
62
+ post_install_message: Thank you for installing Task Tracker CLI by Sulman Baig!
63
+ rdoc_options: []
64
+ require_paths:
65
+ - lib
66
+ required_ruby_version: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: 2.5.0
71
+ required_rubygems_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ requirements: []
77
+ rubygems_version: 3.5.21
78
+ signing_key:
79
+ specification_version: 4
80
+ summary: A CLI tool for tracking tasks.
81
+ test_files: []