aoc_cli 0.2.3 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (151) hide show
  1. checksums.yaml +4 -4
  2. data/.rspec +1 -0
  3. data/.rubocop.yml +88 -0
  4. data/.ruby-version +1 -0
  5. data/Gemfile +8 -0
  6. data/Gemfile.lock +187 -0
  7. data/README.md +88 -282
  8. data/Rakefile +9 -2
  9. data/Steepfile +13 -0
  10. data/aoc_cli.gemspec +36 -26
  11. data/db/migrate/1_create_events.rb +14 -0
  12. data/db/migrate/2_create_puzzles.rb +21 -0
  13. data/db/migrate/3_create_stats.rb +19 -0
  14. data/db/migrate/4_create_attempts.rb +19 -0
  15. data/db/migrate/5_create_locations.rb +17 -0
  16. data/db/migrate/6_create_puzzle_dir_sync_logs.rb +18 -0
  17. data/exe/aoc +5 -0
  18. data/lib/aoc_cli/components/attempts_table.erb +5 -0
  19. data/lib/aoc_cli/components/attempts_table.rb +58 -0
  20. data/lib/aoc_cli/components/docs_component.erb +19 -0
  21. data/lib/aoc_cli/components/docs_component.rb +41 -0
  22. data/lib/aoc_cli/components/errors_component.erb +8 -0
  23. data/lib/aoc_cli/components/errors_component.rb +36 -0
  24. data/lib/aoc_cli/components/progress_table.erb +1 -0
  25. data/lib/aoc_cli/components/progress_table.rb +43 -0
  26. data/lib/aoc_cli/components/puzzle_sync_component.erb +2 -0
  27. data/lib/aoc_cli/components/puzzle_sync_component.rb +26 -0
  28. data/lib/aoc_cli/configurators/session_configurator.rb +7 -0
  29. data/lib/aoc_cli/controllers/application_controller.rb +27 -0
  30. data/lib/aoc_cli/controllers/concerns/error_concern.rb +17 -0
  31. data/lib/aoc_cli/controllers/concerns/location_concern.rb +79 -0
  32. data/lib/aoc_cli/controllers/default_controller.rb +9 -0
  33. data/lib/aoc_cli/controllers/event_controller.rb +35 -0
  34. data/lib/aoc_cli/controllers/help/event_controller.rb +11 -0
  35. data/lib/aoc_cli/controllers/help/puzzle_controller.rb +13 -0
  36. data/lib/aoc_cli/controllers/puzzle_controller.rb +39 -0
  37. data/lib/aoc_cli/core/attempt_parser.rb +69 -0
  38. data/lib/aoc_cli/core/processor.rb +32 -0
  39. data/lib/aoc_cli/core/repository.rb +74 -0
  40. data/lib/aoc_cli/core/request.rb +37 -0
  41. data/lib/aoc_cli/core/resource.rb +39 -0
  42. data/lib/aoc_cli/core/stats_parser.rb +43 -0
  43. data/lib/aoc_cli/helpers/table_generator.rb +64 -0
  44. data/lib/aoc_cli/helpers/view_helper.rb +35 -0
  45. data/lib/aoc_cli/models/attempt.rb +67 -0
  46. data/lib/aoc_cli/models/event.rb +9 -0
  47. data/lib/aoc_cli/models/location.rb +24 -0
  48. data/lib/aoc_cli/models/puzzle.rb +28 -0
  49. data/lib/aoc_cli/models/puzzle_dir_sync_log.rb +14 -0
  50. data/lib/aoc_cli/models/stats.rb +43 -0
  51. data/lib/aoc_cli/presenters/attempt_presenter.rb +29 -0
  52. data/lib/aoc_cli/presenters/puzzle_presenter.rb +29 -0
  53. data/lib/aoc_cli/presenters/stats_presenter.rb +32 -0
  54. data/lib/aoc_cli/processors/event_initialiser.rb +64 -0
  55. data/lib/aoc_cli/processors/puzzle_dir_synchroniser.rb +80 -0
  56. data/lib/aoc_cli/processors/puzzle_initialiser.rb +91 -0
  57. data/lib/aoc_cli/processors/puzzle_refresher.rb +27 -0
  58. data/lib/aoc_cli/processors/resource_attacher.rb +22 -0
  59. data/lib/aoc_cli/processors/solution_poster.rb +72 -0
  60. data/lib/aoc_cli/processors/stats_initialiser.rb +36 -0
  61. data/lib/aoc_cli/processors/stats_refresher.rb +23 -0
  62. data/lib/aoc_cli/validators/collection_type_validator.rb +57 -0
  63. data/lib/aoc_cli/validators/event_year_validator.rb +42 -0
  64. data/lib/aoc_cli/validators/included_validator.rb +21 -0
  65. data/lib/aoc_cli/validators/integer_validator.rb +32 -0
  66. data/lib/aoc_cli/validators/path_validator.rb +39 -0
  67. data/lib/aoc_cli/validators/type_validator.rb +54 -0
  68. data/lib/aoc_cli/version.rb +1 -1
  69. data/lib/aoc_cli/views/event/attach.erb +3 -0
  70. data/lib/aoc_cli/views/event/init.erb +3 -0
  71. data/lib/aoc_cli/views/help/event/attach.erb +32 -0
  72. data/lib/aoc_cli/views/help/event/init.erb +38 -0
  73. data/lib/aoc_cli/views/help/event/progress.erb +12 -0
  74. data/lib/aoc_cli/views/help/puzzle/attempts.erb +12 -0
  75. data/lib/aoc_cli/views/help/puzzle/init.erb +31 -0
  76. data/lib/aoc_cli/views/help/puzzle/solve.erb +33 -0
  77. data/lib/aoc_cli/views/help/puzzle/sync.erb +32 -0
  78. data/lib/aoc_cli/views/puzzle/init.erb +3 -0
  79. data/lib/aoc_cli/views/puzzle/solve.erb +10 -0
  80. data/lib/aoc_cli.rb +32 -16
  81. data/rbs_collection.lock.yaml +168 -0
  82. data/rbs_collection.yaml +28 -0
  83. data/sig/aoc_cli/components/attempts_table.rbs +29 -0
  84. data/sig/aoc_cli/components/docs_component.rbs +15 -0
  85. data/sig/aoc_cli/components/errors_component.rbs +19 -0
  86. data/sig/aoc_cli/components/progress_table.rbs +28 -0
  87. data/sig/aoc_cli/components/puzzle_sync_component.rbs +19 -0
  88. data/sig/aoc_cli/configurators/session_configurator.rbs +7 -0
  89. data/sig/aoc_cli/controllers/application_controller.rbs +12 -0
  90. data/sig/aoc_cli/controllers/concerns/error_concern.rbs +9 -0
  91. data/sig/aoc_cli/controllers/concerns/location_concern.rbs +35 -0
  92. data/sig/aoc_cli/controllers/default_controller.rbs +7 -0
  93. data/sig/aoc_cli/controllers/event_controller.rbs +18 -0
  94. data/sig/aoc_cli/controllers/help/event_controller.rbs +11 -0
  95. data/sig/aoc_cli/controllers/help/puzzle_controller.rbs +13 -0
  96. data/sig/aoc_cli/controllers/puzzle_controller.rbs +15 -0
  97. data/sig/aoc_cli/core/attempt_parser.rbs +41 -0
  98. data/sig/aoc_cli/core/processor.rbs +25 -0
  99. data/sig/aoc_cli/core/repository.rbs +25 -0
  100. data/sig/aoc_cli/core/request.rbs +29 -0
  101. data/sig/aoc_cli/core/resource.rbs +25 -0
  102. data/sig/aoc_cli/core/stats_parser.rbs +23 -0
  103. data/sig/aoc_cli/helpers/table_generator.rbs +36 -0
  104. data/sig/aoc_cli/helpers/view_helper.rbs +15 -0
  105. data/sig/aoc_cli/models/attempt.rbs +35 -0
  106. data/sig/aoc_cli/models/event.rbs +17 -0
  107. data/sig/aoc_cli/models/location.rbs +19 -0
  108. data/sig/aoc_cli/models/puzzle.rbs +28 -0
  109. data/sig/aoc_cli/models/puzzle_dir_sync_log.rbs +11 -0
  110. data/sig/aoc_cli/models/stats.rbs +53 -0
  111. data/sig/aoc_cli/presenters/attempt_presenter.rbs +13 -0
  112. data/sig/aoc_cli/presenters/puzzle_presenter.rbs +19 -0
  113. data/sig/aoc_cli/presenters/stats_presenter.rbs +19 -0
  114. data/sig/aoc_cli/processors/event_initialiser.rbs +26 -0
  115. data/sig/aoc_cli/processors/puzzle_dir_synchroniser.rbs +40 -0
  116. data/sig/aoc_cli/processors/puzzle_initialiser.rbs +37 -0
  117. data/sig/aoc_cli/processors/puzzle_refresher.rbs +21 -0
  118. data/sig/aoc_cli/processors/resource_attacher.rbs +16 -0
  119. data/sig/aoc_cli/processors/solution_poster.rbs +34 -0
  120. data/sig/aoc_cli/processors/stats_initialiser.rbs +15 -0
  121. data/sig/aoc_cli/processors/stats_refresher.rbs +19 -0
  122. data/sig/aoc_cli/validators/collection_type_validator.rbs +24 -0
  123. data/sig/aoc_cli/validators/event_year_validator.rbs +19 -0
  124. data/sig/aoc_cli/validators/included_validator.rbs +11 -0
  125. data/sig/aoc_cli/validators/integer_validator.rbs +15 -0
  126. data/sig/aoc_cli/validators/path_validator.rbs +17 -0
  127. data/sig/aoc_cli/validators/type_validator.rbs +22 -0
  128. data/sig/aoc_cli.rbs +6 -0
  129. data/sig/http.rbs +3 -0
  130. data/sig/kangaru.rbs +5 -0
  131. data/sig/nokogiri.rbs +3 -0
  132. data/sig/reverse_markdown.rbs +3 -0
  133. metadata +142 -34
  134. data/.gitignore +0 -5
  135. data/bin/aoc +0 -4
  136. data/bin/console +0 -15
  137. data/bin/setup +0 -7
  138. data/lib/aoc_cli/commands.rb +0 -232
  139. data/lib/aoc_cli/database.rb +0 -224
  140. data/lib/aoc_cli/day.rb +0 -124
  141. data/lib/aoc_cli/db/reddit.db +0 -0
  142. data/lib/aoc_cli/errors.rb +0 -275
  143. data/lib/aoc_cli/files.rb +0 -163
  144. data/lib/aoc_cli/help.rb +0 -77
  145. data/lib/aoc_cli/interface.rb +0 -81
  146. data/lib/aoc_cli/paths.rb +0 -101
  147. data/lib/aoc_cli/solve.rb +0 -104
  148. data/lib/aoc_cli/tables.rb +0 -138
  149. data/lib/aoc_cli/tools.rb +0 -120
  150. data/lib/aoc_cli/year.rb +0 -116
  151. data/sample/aoc.rc +0 -21
data/README.md CHANGED
@@ -1,71 +1,39 @@
1
- # `Advent of Code - cli`
1
+ # `aoc-cli`
2
2
 
3
- ![](https://github.com/apexatoll/aoc-files/blob/master/demo2.gif)
3
+ A command-line interface for Advent of Code, built in Ruby.
4
+
5
+ > [!IMPORTANT]
6
+ > `aoc_cli` has gone through a complete rewrite as of `1.0.0` in order to improve resilience and the overall user interface.
7
+ > The core application has been swapped out to use the [Kangaru](https://github.com/apexatoll/kangaru) command line framework, with a completely new API and removal of bloated features.
8
+ > There are also some other improvements on performance, and removal of some hefty dependencies such as `pandoc`.
9
+ > These are breaking changes, so please pin your version to `0.2.3` if you wish to continue using the previous version.
4
10
 
5
- A command-line interface to interact with Advent of Code puzzles, built in Ruby.
6
11
 
7
12
  ## Main Features
13
+
8
14
  - Download puzzles as markdown and raw inputs directly from the command line
9
15
  - Submit answers for puzzles and receive feedback
10
- - Track progress through your calendar file which is automatically updated as you progress
11
- - View data about how you answer puzzles, for example your previous attempts, how long it takes to solve a puzzle successfully and how many attempts it took you
12
- - Inputs and puzzles are cached locally to prevent strain on AoC server
13
- - Automatic git initialisation
14
- - Hot keys to open solution megathreads in Reddit if you get stuck
15
- - Support for multiple AoC accounts by use of session-key aliases
16
-
17
- ### Note to Existing Users
18
- - If you are having any issues with the calendar table, run `aoc -r` in your year directory to update and refresh your directory
19
-
20
- ## Whats New
21
-
22
- ### New to 0.2.2
23
- - Year refresh now creates the calendar table if it does not exist
24
- - Update terminal-table version requirements
25
- - Add version flag
26
-
27
- ### New to 0.2.1
28
- - Day subdir prefix functionality
29
- - Duplicate incorrect attempts prevented
30
-
31
- ### New to 0.2.0
32
- - Calendar progress tables
33
- - Quick-print calendar from any directory
34
- - Configuration expansion
35
- - Auto-generate config file
36
- - Turn on/off creation of calendar file
37
- - Turn on/off leaderboard stats in calendar file
38
- - Basic git integration
39
- - Better key validation
40
- - Better default alias handling
41
- - General bug fixes
16
+ - Track data on your progress through the event
42
17
 
43
18
 
44
19
  ## Installation
45
20
 
46
- - aoc-cli uses Pandoc, make sure it is [installed](https://pandoc.org/installing.html)
47
- - Homebrew users can run `brew install pandoc`
48
- - Mac OS users need to make sure developer tools is installed (thank you yspreen)
49
-
50
- Install gem
21
+ - As of `1.0.0`, `aoc_cli` no longer requires `pandoc`
22
+ - Other system requirements are `curl` and `sqlite3` and `ruby` >= `3.2.0`
51
23
 
52
- ```bash
53
- $ gem install aoc_cli
54
- ```
55
24
 
56
- Manual install
25
+ Install `aoc_cli` with the following command
57
26
 
58
27
  ```bash
59
- $ git clone "https://github.com/apexatoll/aoc-cli"
60
- $ cd aoc-cli
61
- $ rake build install
28
+ gem install aoc_cli
62
29
  ```
63
30
 
31
+
64
32
  ## Setup
65
33
 
66
- ### Finding your Session Key
34
+ ### Setting your Session Key
67
35
 
68
- To use aoc-cli you must first find and store your unique session cookie. To find this, log into the Advent of Code website as usual and load any page.
36
+ To use `aoc-cli` you must first find and store your unique session cookie. To find this, log into the Advent of Code website as usual and load any page.
69
37
 
70
38
  Open developer tools and open the network tab. Refresh the page and you should see a file that contains your session cookie.
71
39
 
@@ -75,314 +43,152 @@ It will contain a field that looks something like:
75
43
  cookie: session=HEXADECIMAL_STRING
76
44
  ```
77
45
 
78
- This is unique to your account, and allows aoc-cli to interact with the AoC server - do not share this!
46
+ This is unique to your account, and allows `aoc-cli` to interact with the AoC server on your behalf - do not share this or check this into version control.
79
47
 
48
+ Your session token should be copied into your configuration file (`~/.config/aoc_cli/config.yml`) under the `session.token` nested key:
80
49
 
81
- ### Storing your Session Key
82
-
83
- - Copy the session key (including "session=") to the clipboard and open your terminal
84
- - Run the following command
85
-
86
- ```bash
87
- aoc -k $your_key
88
-
50
+ ```yaml
51
+ session:
52
+ token: <YOUR TOKEN>
89
53
  ```
90
54
 
91
- - aoc-cli stores this key under the alias 'main' if no custom alias is specified
92
- - To store the key under a different alias use the `-u` or `--user` flags followed by the desired alias.
93
- - Session keys are stored in the aoc config file located at `~/.config/aoc-cli/aoc.rc`.
55
+ > [!IMPORTANT]
56
+ > Make sure to strip the `session=` prefix from the copied token.
94
57
 
95
- Keys can also be stored manually in your config file using the format:
58
+ > [!NOTE]
59
+ > Multiple users used to be a feature pre the 1.0.0 overhaul. This will be
60
+ > reimplemented and released in an upcoming release if there is need for it.
96
61
 
97
- ```
98
- cookie=>$alias=>$key
99
- ```
100
-
101
- For example:
102
-
103
- ```
104
- cookie=>account2=>session=123abc
105
- ```
106
62
 
107
- ### Default Alias
108
-
109
- aoc-cli allows for multiple keys to be stored within the config file.
110
-
111
- To see which alias is currently default run `aoc -U` or `aoc --default`
112
-
113
- - You can update the default alias by running
114
-
115
- ```bash
116
- aoc -U $new_default_alias
117
- ```
118
-
119
- By default, aoc-cli will determine the default alias in the following order of precedence
120
-
121
- - The alias explicitly set by `default=>$alias` in your config file or by using the `-U` command
122
- - The `main` alias (if it exists)
123
- - The first key in your config file
124
-
125
- ### Use Case
63
+ ## Usage
126
64
 
127
- Say for example you wanted to learn a new language and decided to try out Advent of Code from scratch to get stuck in. You could set up a new account and grab the session key, which for example is `abc123`
65
+ `aoc-cli` is designed to run in a file-tree generated by the application.
128
66
 
129
- Lets use Ruby as our new language. You could then store this new key under the alias `ruby`
67
+ There are two types of directories
130
68
 
131
- ```bash
132
- aoc -k session=abc123 -u ruby
133
- ```
69
+ 1. Event directories
70
+ - These contain puzzle subdirectories
134
71
 
135
- You could then set `ruby` as your default alias so that you do not have to specify `-u ruby` explicitly when initialising a year directory each time
72
+ 2. Puzzle subdirectories
73
+ - These contain puzzles, input and your soution code
136
74
 
137
- ```bash
138
- aoc -U ruby
139
- ```
140
- Alternatively you could add the following line to your config file
75
+ ### Directory Structure Example
141
76
 
142
77
  ```
143
- default=>ruby
78
+ 2023 <--- Event Directory
79
+
80
+ ├── 1 <-- Puzzle Directory
81
+ │ │
82
+ │   ├── day_1.md
83
+ │   ├── input
84
+ │   └── solution.rb
85
+ └── 2
86
+ ├── day_2.md
87
+ ├── input
88
+ └── solution.rs
144
89
  ```
145
90
 
146
- ## Usage
147
-
148
- aoc-cli is designed to run in a file-tree generated by the interface.
149
-
150
- There are two types of directories
151
- 1. Year directories
152
- - These contain your calendar and all day subdirectories
153
- 2. Day subdirectories
154
- - These contain the puzzles, your input and your code
155
-
156
- ## Initialising the Year
91
+ ### Initialising an Event
157
92
 
158
- To begin using the cli you must first initialise the year directory.
93
+ To begin using the cli you must first initialise an event directory. An event directory is the parent directory in which your puzzle directories (and your code solutions) exist.
159
94
 
160
- aoc-cli will intialise within your current working directory, so first create a directory for the year and change directory into it
95
+ > [!NOTE]
96
+ > If you are planning on tackling multiple Advent of Code events, it is probably wise to create a root for your event directories, eg `~/aoc`.
161
97
 
162
- ```bash
163
- mkdir 2020
164
- cd 2020
165
- ```
166
- Initialise the year directory using the command
98
+ To initialize an event, run the following command:
167
99
 
168
100
  ```bash
169
- aoc -y 2020
101
+ aoc event init <YEAR>
170
102
  ```
171
103
 
172
- This will set the session key for the year directory to the default alias. To use a different alias run:
173
-
174
- ```bash
175
- aoc -y 2020 -u $alias
176
- ```
104
+ This will:
177
105
 
178
- This command will create necessary metafiles, download the year calendar and fill it with your current progress (if any). This is stored in a markdown file in the year directory.
106
+ - Fetch your latest stats and setup your progress
107
+ - Create an event directory
179
108
 
180
- By default, your stats in the leaderboard are also added to this file. This can be changed - see Configuration
109
+ At the time of writing, the valid years are 2015 - 2023.
181
110
 
182
- aoc-cli can also intialise a git directory on year intialisation (turned off by default)
183
111
 
184
- ## Initialising a Day
112
+ ### Initialising a Puzzle
185
113
 
186
- You can now get day data!
114
+ > [!CAUTION]
115
+ > Please do not check puzzle or input files into your version control system, as this is against Advent of Code rules.
187
116
 
188
- To fetch puzzle instructions and inputs you can run the following command from within the year directory
117
+ Run the following command from an event directory to fetch and initialize a puzzle directory and associated files:
189
118
 
190
119
  ```bash
191
- aoc -d $day_number
120
+ aoc puzzle init <DAY>
192
121
  ```
193
122
 
194
123
  This command performs the following actions
195
124
 
196
- - Creates a day subdirectory
197
- - Fetches the puzzle as markdown
198
- - Fetches raw puzzle input
199
- - The time you downloaded the puzzle is logged
125
+ - Creates a puzzle subdirectory
126
+ - Fetches the puzzle as markdown and writes to the puzzle dir
127
+ - Fetches raw puzzle input and writes to the puzzle dir
200
128
 
201
- All puzzles and inputs are cached in aoc-cli on a per-user basis. This means that if you have previously initialised this day under the same alias before, your puzzle and input will be transferred from the cache locally rather than downloading from the aoc server.
129
+ This directory is a good place to write your solution code adjacent to your input and puzzle files.
202
130
 
203
- NB: if you wish to add a prefix to your day subdirectory names, you can add `day_dir_prefix=>$prefix` to your config file
204
131
 
205
- ## Solving Puzzles
132
+ ### Solving Puzzles
206
133
 
207
- From the day subdirectory you can attempt to solve puzzles by running the command
134
+ From the puzzle subdirectory you can solve puzzles by running the command
208
135
 
209
136
  ```bash
210
- aoc -s $answer
137
+ aoc puzzle solve --answer <ANSWER>
211
138
  ```
212
139
 
213
- You will then receive one of four responses
140
+ You will then receive one of three responses
214
141
 
215
- 1. The answer is correct
216
- 2. The answer is not correct
217
- 3. You have already tried this incorrect answer
218
- 4. You have time to wait before submitting an answer
142
+ 1. The answer was correct
143
+ 2. The answer was not correct
144
+ 3. You have time to wait before submitting an answer
219
145
 
220
- If your answer is correct, aoc-cli will automatically update the puzzle instructions and your calendar file. Additionally aoc-cli will calculate how long and how many attempts it took to solve the puzzle (see the Tables section)
146
+ If your answer is correct, `aoc-cli` will automatically update the puzzle instructions and your event progress.
221
147
 
222
- Incorrect attempts will be logged along with any hint as to whether your answer was too high or too low.
148
+ Incorrect attempts will be logged along with any hint as to whether your answer was too high or too low. You can recall these using the `puzzle attempts` command.
223
149
 
224
- Trying to answer with the same incorrect answer for the second time will throw an error
225
-
226
- If you have sent multiple incorrect attempts AoC will ask you to wait before trying again - be patient!
150
+ If you have sent multiple incorrect attempts AoC will ask you to wait before trying to answer the puzzle again.
227
151
 
228
152
 
229
153
  ## Tables
230
154
 
231
- aoc-cli uses a local database to store information about your progress with puzzles. This tracks data on:
155
+ `aoc-cli` uses a local SQLite database to store information about your progress with puzzles. This tracks data on:
232
156
 
233
- 1. Your attempts
234
- 2. Your stats
235
- 3. Your progress in the year
157
+ 1. Your progress for the current event
158
+ 1. Your attempts for the current puzzle
236
159
 
237
160
  This data can be visualised in terminal-friendly tables
238
161
 
239
- ### Attempts
240
-
241
- Previous attempts for a puzzle can be viewed from the day directory by the use of the command
242
-
243
- ```bash
244
- aoc -a (--attempts)
245
- ```
246
-
247
- To specify which attempts to show from outside the day subdirectory you can use the command
248
-
249
- ```bash
250
- aoc -a -u $user_alias -Y $year -D $day -p $part
251
- ```
252
-
253
- Data is shown in a formatted table with incorrect attempts shown in red and the correct answer in green.
254
-
255
- ![](https://github.com/apexatoll/aoc-files/blob/master/attempts.png)
256
-
257
- You need to specify the part explicitly using `-p` or `--part` to view attempts for puzzles that are already completed
258
162
 
259
- ### Stats
260
-
261
- aoc-cli also tracks data related to your performance in puzzles, namely:
262
- - The time taken to complete a puzzle
263
- - How many attempts it took
163
+ ### Attempts
264
164
 
265
- To view stats on a specific puzzle run the following command from the day subdirectory
165
+ Previous attempts for a puzzle can be viewed from the puzzle directory by the use of the command:
266
166
 
267
167
  ```bash
268
- aoc -S (--stats)
168
+ aoc puzzle attempts
269
169
  ```
270
170
 
271
- To view the stats for the year as a whole run the same command from the year directory.
272
-
273
- Flags can be also be added manually for showing data for other users, years and days in a similar way to that of the attempts table
274
-
275
- ![](https://github.com/apexatoll/aoc-files/blob/master/stats.png)
276
-
277
171
  ### Progress
278
172
 
279
- To view your progress in the year you can run the commands
173
+ To view your progress in the year you can run the following command from within an event or a puzzle directory.
280
174
 
281
175
  ```bash
282
- aoc -c (--simple-cal)
176
+ aoc event progress
283
177
  ```
284
178
 
285
179
  This will print a simple table showing your stars for each day. This is created on year initialisation and updated as you complete puzzles
286
180
 
287
- If you have calendar_file set to true in your configuration (default setting), you can quickly print your calendar file by using the command
288
-
289
- ```bash
290
- aoc -C (--fancy-cal)
291
- ```
292
-
293
- ![calendars](https://github.com/apexatoll/aoc-files/blob/master/calendars.gif)
294
-
295
- ## Reddit Integration
296
-
297
- ![reddit](https://github.com/apexatoll/aoc-files/blob/master/reddit.gif)
298
-
299
- You can run the command `aoc -R (--reddit)` from the day subdirectory, or by manual flags to open the solution megathread for the specified day in Reddit
300
-
301
- If one is installed, aoc-cli will default to opening the thread within a
302
- reddit-cli such as [rtv](https://github.com/michael-lazar/rtv) or [ttrv](https://github.com/tildeclub/ttrv).
303
-
304
- If one isn't found however, the thread will be opened within your default browser.
305
-
306
- To open the reddit megathread in your browser, regardless of whether you have a CLI installed, run `aoc -B (--browser)`
307
-
308
- ## Git Integration
309
-
310
- aoc-cli currently supports basic integration with git. At present aoc-cli can:
311
- - Initialise a git directory on year initialisation
312
- - Create a gitignore file
313
- - Configurable to add markdown and metafiles by default
314
181
 
315
- These settings can be configured in your config file (see configuration)
182
+ ## Help
316
183
 
317
- ## Vim Integration
184
+ `aoc-cli` also has built in documentation. You can view this from the terminal using either `aoc help <COMMAND>` or `aoc <COMMAND> --help`.
318
185
 
319
- If you use vim you may wish to set a keybinding to automatically run your code and submit it for validation once you have solved a puzzle.
320
186
 
321
- Using Ruby as an example, you could add the following line to your .vimrc:
187
+ ## Contributing
322
188
 
323
- ```vim
324
- autocmd filetype ruby nmap <silent><leader>ac :! aoc -s $(ruby %)<CR>
325
- ```
326
-
327
- Executing leader + ac would then run your program and send the answer to the server for verification (as long as your program only outputs an answer and no other text).
328
-
329
- ## Configuration
330
-
331
- aoc-cli can be configured using the config file at `~/.config/aoc-cli/aoc.rc`
332
-
333
- To generate an example configuration file you can run `aoc -G` or `aoc --gen-config`. (Note this will throw an error if `~/.config/aoc-cli/aoc.rc` already exists)
334
-
335
- There is also an example aoc.rc file in the `sample` directory of this repo
189
+ Please create an issue if there are any bugs or problems using `aoc-cli`. Contributions and questions are always welcome.
336
190
 
337
- Settings are added to the aoc-cli config file in the format
338
-
339
- ```
340
- setting_name=>setting
341
- ```
342
-
343
- Lines can be commented out of the rc file by prefixing with `//`
344
-
345
- ### List of Configurable Options
346
-
347
- | Flag | Type | Description | Default |
348
- |-------------------|--------|---------------------------------------------------------------|---------|
349
- | calendar_file | bool | Write calendar as a markdown file | true |
350
- | day_dir_prefix | string | Add prefix to day subdirectory nam | nil |
351
- | default | string | Default alias | main |
352
- | ignore_md_files | bool | Auto add md files (calendar and puzzles) to gitignore | true |
353
- | ignore_meta_files | bool | Auto add meta files to gitignore | true |
354
- | init_git | bool | Initialise a git repository on year initialisation | false |
355
- | lb_in_calendar | bool | Include leaderboard stats in calendar file | true |
356
- | reddit_in_browser | bool | Always open reddit links in browser | false |
357
- | unicode_tables | bool | Display tables in unicode format. Otherwise ascii format used | true |
358
-
359
-
360
- ## All Flags
361
-
362
- | Flag Short | Flag Long | Action |
363
- |------------|----------------|------------------------------------------------------|
364
- | `-a` | `--attempts` | Print attempts table |
365
- | `-B` | `--browser` | View reddit megathread in your browser |
366
- | `-c` | `--simple-cal` | Print simplified calendar progress |
367
- | `-C` | `--fancy-cal` | Print styled calendar (requires calendar_file=>true) |
368
- | `-d` | `--init-day` | Initialise day subdirectory |
369
- | `-D` | `--day` | Manual day specification for aoc command |
370
- | `-G` | `--gen-config` | Write example config file |
371
- | `-h` | `--help` | Show help screen |
372
- | `-k` | `--key` | Store session key |
373
- | `-p` | `--part` | Manual part specification for aoc command |
374
- | `-r` | `--refresh` | Refresh calendar (year dir) |
375
- | | | Refresh puzzle (day subdir) |
376
- | `-R` | `--reddit` | Open solution megathread |
377
- | `-s` | `--solve` | Solve puzzle |
378
- | `-S` | `--stats` | Print stats table |
379
- | `-u` | `--user` | Specify alias for aoc command |
380
- | `-U` | `--default` | View default alias, list all aliases (no argument) |
381
- | `-y` | `--init-year` | Initialise year directory |
382
- | `-Y` | `--year` | Specify year for aoc command |
383
191
 
384
192
  ## Acknowledgments
385
193
 
386
- I am in no way affiliated with AoC, but I would like to take this opportunity to thank the creator Eric Wastl for the taking the time and great effort to produce these fantastic puzzles!
387
-
388
- Please let me know if there are any bugs or issues with the cli within the issues section - I will try to address them as quickly as I can
194
+ `aoc-cli` is in no way affiliated with Advent of Code, but I would like to take this opportunity to thank the creator, Eric Wastl, for his efforts in producing these fantastic puzzles year on year.
data/Rakefile CHANGED
@@ -1,3 +1,10 @@
1
- # frozen_string_literal: true
2
1
  require "bundler/gem_tasks"
3
- task default: %i[]
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ require "rubocop/rake_task"
7
+
8
+ RuboCop::RakeTask.new
9
+
10
+ task default: %i[spec rubocop]
data/Steepfile ADDED
@@ -0,0 +1,13 @@
1
+ target :lib do
2
+ signature "sig"
3
+
4
+ check "lib"
5
+
6
+ configure_code_diagnostics do |hash|
7
+ hash[Steep::Diagnostic::Ruby::FallbackAny] = nil
8
+ hash[Steep::Diagnostic::Ruby::UnreachableBranch] = nil
9
+ hash[Steep::Diagnostic::Ruby::UnknownConstant] = :error
10
+ hash[Steep::Diagnostic::Ruby::MethodDefinitionMissing] = nil
11
+ hash[Steep::Diagnostic::Ruby::UnsupportedSyntax] = :hint
12
+ end
13
+ end
data/aoc_cli.gemspec CHANGED
@@ -1,30 +1,40 @@
1
1
  require_relative "lib/aoc_cli/version"
2
2
 
3
3
  Gem::Specification.new do |spec|
4
- spec.name = "aoc_cli"
5
- spec.version = AocCli::VERSION
6
- spec.authors = ["Christian Welham"]
7
- spec.email = ["welhamm@gmail.com"]
8
- spec.summary = "A command-line interface for the Advent of Code puzzles"
9
- spec.description = "A command-line interface for the Advent of Code puzzles. Features include downloading puzzles and inputs, solving puzzles and tracking year progress from within the terminal"
10
- spec.homepage = "https://github.com/apexatoll/aoc-cli"
11
- spec.license = "MIT"
12
- spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
13
- spec.metadata["homepage_uri"] = spec.homepage
14
- spec.metadata["source_code_uri"] = "https://github.com/apexatoll/aoc-cli"
15
- spec.metadata["changelog_uri"] = "https://github.com/apexatoll/aoc-cli/CHANGELOG.md"
16
- spec.files = Dir.chdir(File.expand_path(__dir__)) do
17
- `git ls-files -z`
18
- .split("\x0")
19
- .reject{|f| f.match(%r{\A(?:test|spec|features)/}) }
20
- end
21
- spec.bindir = "bin"
22
- spec.executables << 'aoc'
23
- spec.require_paths = ["lib"]
24
- spec.add_dependency("colorize")
25
- spec.add_dependency("curb")
26
- spec.add_dependency("git")
27
- spec.add_dependency("pandoc-ruby")
28
- spec.add_dependency("sqlite3")
29
- spec.add_dependency("terminal-table", "~> 3.0.0")
4
+ spec.name = "aoc_cli"
5
+ spec.version = AocCli::VERSION
6
+ spec.authors = ["Christian Welham"]
7
+ spec.email = ["welhamm@gmail.com"]
8
+
9
+ spec.summary = "A command-line interface for the Advent of Code puzzles"
10
+
11
+ spec.description = <<~DESCRIPTION
12
+ A command-line interface for the Advent of Code puzzles. Features include \
13
+ downloading puzzles and inputs, solving puzzles and tracking year progress \
14
+ from within the terminal
15
+ DESCRIPTION
16
+
17
+ spec.homepage = "https://github.com/apexatoll/aoc-cli"
18
+ spec.license = "MIT"
19
+ spec.required_ruby_version = ">= 3.2.0"
20
+
21
+ spec.metadata["homepage_uri"] = spec.homepage
22
+ spec.metadata["source_code_uri"] = "https://github.com/apexatoll/aoc-cli"
23
+
24
+ spec.files = Dir.chdir(__dir__) do
25
+ `git ls-files -z`.split("\x0").reject do |f|
26
+ f == __FILE__ || f.match?(/\A(bin|spec|\.git)/)
27
+ end
28
+ end
29
+
30
+ spec.bindir = "exe"
31
+ spec.executables = ["aoc"]
32
+ spec.require_paths = ["lib"]
33
+
34
+ spec.add_dependency "http"
35
+ spec.add_dependency "kangaru"
36
+ spec.add_dependency "nokogiri"
37
+ spec.add_dependency "reverse_markdown"
38
+ spec.add_dependency "sequel_polymorphic"
39
+ spec.add_dependency "terminal-table"
30
40
  end
@@ -0,0 +1,14 @@
1
+ Sequel.migration do
2
+ change do
3
+ create_table :events do
4
+ primary_key :id
5
+
6
+ integer :year, null: false
7
+
8
+ datetime :created_at
9
+ datetime :updated_at
10
+
11
+ index :year
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,21 @@
1
+ Sequel.migration do
2
+ change do
3
+ create_table :puzzles do
4
+ primary_key :id
5
+
6
+ foreign_key :event_id, :events, null: false
7
+
8
+ integer :day, null: false
9
+
10
+ text :content, null: false
11
+ text :input, null: false
12
+
13
+ datetime :created_at
14
+ datetime :updated_at
15
+ datetime :part_one_completed_at
16
+ datetime :part_two_completed_at
17
+
18
+ index :event_id
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,19 @@
1
+ Sequel.migration do
2
+ change do
3
+ create_table :stats do
4
+ primary_key :id
5
+
6
+ foreign_key :event_id, :events, null: false
7
+
8
+ 1.upto(25) do |i|
9
+ integer :"day_#{i}", null: false, default: 0
10
+ end
11
+
12
+ datetime :created_at
13
+ datetime :updated_at
14
+ datetime :completed_at
15
+
16
+ index :event_id
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,19 @@
1
+ Sequel.migration do
2
+ change do
3
+ create_table :attempts do
4
+ primary_key :id
5
+
6
+ foreign_key :puzzle_id, :puzzles, null: false
7
+
8
+ integer :level, null: false
9
+ text :answer, null: false
10
+
11
+ integer :status, null: false
12
+ integer :hint
13
+ integer :wait_time
14
+
15
+ datetime :created_at
16
+ datetime :updated_at
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,17 @@
1
+ Sequel.migration do
2
+ change do
3
+ create_table :locations do
4
+ primary_key :id
5
+
6
+ string :path, null: false
7
+
8
+ integer :resource_id, null: false
9
+ string :resource_type, null: false
10
+
11
+ datetime :created_at
12
+ datetime :updated_at
13
+
14
+ index %i[path resource_id resource_type]
15
+ end
16
+ end
17
+ end