aoc_cli 0.2.3 → 1.0.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 +4 -4
- data/.rspec +1 -0
- data/.rubocop.yml +88 -0
- data/.ruby-version +1 -0
- data/Gemfile +8 -0
- data/Gemfile.lock +187 -0
- data/README.md +88 -282
- data/Rakefile +9 -2
- data/Steepfile +13 -0
- data/aoc_cli.gemspec +36 -26
- data/db/migrate/1_create_events.rb +14 -0
- data/db/migrate/2_create_puzzles.rb +21 -0
- data/db/migrate/3_create_stats.rb +19 -0
- data/db/migrate/4_create_attempts.rb +19 -0
- data/db/migrate/5_create_locations.rb +17 -0
- data/db/migrate/6_create_puzzle_dir_sync_logs.rb +18 -0
- data/db/migrate/7_create_progresses.rb +17 -0
- data/db/migrate/8_remove_legacy_timestamps.rb +8 -0
- data/exe/aoc +5 -0
- data/lib/aoc_cli/components/attempts_table.erb +5 -0
- data/lib/aoc_cli/components/attempts_table.rb +58 -0
- data/lib/aoc_cli/components/docs_component.erb +19 -0
- data/lib/aoc_cli/components/docs_component.rb +41 -0
- data/lib/aoc_cli/components/errors_component.erb +8 -0
- data/lib/aoc_cli/components/errors_component.rb +36 -0
- data/lib/aoc_cli/components/progress_table.erb +1 -0
- data/lib/aoc_cli/components/progress_table.rb +43 -0
- data/lib/aoc_cli/components/puzzle_sync_component.erb +2 -0
- data/lib/aoc_cli/components/puzzle_sync_component.rb +26 -0
- data/lib/aoc_cli/configurators/session_configurator.rb +7 -0
- data/lib/aoc_cli/controllers/application_controller.rb +27 -0
- data/lib/aoc_cli/controllers/concerns/error_concern.rb +17 -0
- data/lib/aoc_cli/controllers/concerns/location_concern.rb +79 -0
- data/lib/aoc_cli/controllers/default_controller.rb +9 -0
- data/lib/aoc_cli/controllers/event_controller.rb +35 -0
- data/lib/aoc_cli/controllers/help/event_controller.rb +11 -0
- data/lib/aoc_cli/controllers/help/puzzle_controller.rb +13 -0
- data/lib/aoc_cli/controllers/puzzle_controller.rb +39 -0
- data/lib/aoc_cli/core/attempt_parser.rb +69 -0
- data/lib/aoc_cli/core/processor.rb +32 -0
- data/lib/aoc_cli/core/repository.rb +74 -0
- data/lib/aoc_cli/core/request.rb +37 -0
- data/lib/aoc_cli/core/resource.rb +39 -0
- data/lib/aoc_cli/core/stats_parser.rb +43 -0
- data/lib/aoc_cli/helpers/table_generator.rb +64 -0
- data/lib/aoc_cli/helpers/view_helper.rb +35 -0
- data/lib/aoc_cli/models/attempt.rb +67 -0
- data/lib/aoc_cli/models/event.rb +9 -0
- data/lib/aoc_cli/models/location.rb +24 -0
- data/lib/aoc_cli/models/progress.rb +33 -0
- data/lib/aoc_cli/models/puzzle.rb +28 -0
- data/lib/aoc_cli/models/puzzle_dir_sync_log.rb +14 -0
- data/lib/aoc_cli/models/stats.rb +43 -0
- data/lib/aoc_cli/presenters/attempt_presenter.rb +29 -0
- data/lib/aoc_cli/presenters/puzzle_presenter.rb +29 -0
- data/lib/aoc_cli/presenters/stats_presenter.rb +32 -0
- data/lib/aoc_cli/processors/event_initialiser.rb +64 -0
- data/lib/aoc_cli/processors/progress_syncer.rb +48 -0
- data/lib/aoc_cli/processors/puzzle_dir_synchroniser.rb +80 -0
- data/lib/aoc_cli/processors/puzzle_initialiser.rb +106 -0
- data/lib/aoc_cli/processors/puzzle_refresher.rb +27 -0
- data/lib/aoc_cli/processors/resource_attacher.rb +22 -0
- data/lib/aoc_cli/processors/solution_poster.rb +72 -0
- data/lib/aoc_cli/processors/stats_initialiser.rb +36 -0
- data/lib/aoc_cli/processors/stats_refresher.rb +23 -0
- data/lib/aoc_cli/validators/collection_type_validator.rb +57 -0
- data/lib/aoc_cli/validators/event_year_validator.rb +42 -0
- data/lib/aoc_cli/validators/included_validator.rb +21 -0
- data/lib/aoc_cli/validators/integer_validator.rb +32 -0
- data/lib/aoc_cli/validators/path_validator.rb +39 -0
- data/lib/aoc_cli/validators/type_validator.rb +54 -0
- data/lib/aoc_cli/version.rb +1 -1
- data/lib/aoc_cli/views/event/attach.erb +3 -0
- data/lib/aoc_cli/views/event/init.erb +3 -0
- data/lib/aoc_cli/views/help/event/attach.erb +32 -0
- data/lib/aoc_cli/views/help/event/init.erb +38 -0
- data/lib/aoc_cli/views/help/event/progress.erb +12 -0
- data/lib/aoc_cli/views/help/puzzle/attempts.erb +12 -0
- data/lib/aoc_cli/views/help/puzzle/init.erb +31 -0
- data/lib/aoc_cli/views/help/puzzle/solve.erb +33 -0
- data/lib/aoc_cli/views/help/puzzle/sync.erb +32 -0
- data/lib/aoc_cli/views/puzzle/init.erb +3 -0
- data/lib/aoc_cli/views/puzzle/solve.erb +10 -0
- data/lib/aoc_cli.rb +36 -16
- data/rbs_collection.lock.yaml +168 -0
- data/rbs_collection.yaml +28 -0
- data/sig/aoc_cli/components/attempts_table.rbs +29 -0
- data/sig/aoc_cli/components/docs_component.rbs +15 -0
- data/sig/aoc_cli/components/errors_component.rbs +19 -0
- data/sig/aoc_cli/components/progress_table.rbs +28 -0
- data/sig/aoc_cli/components/puzzle_sync_component.rbs +19 -0
- data/sig/aoc_cli/configurators/session_configurator.rbs +7 -0
- data/sig/aoc_cli/controllers/application_controller.rbs +12 -0
- data/sig/aoc_cli/controllers/concerns/error_concern.rbs +9 -0
- data/sig/aoc_cli/controllers/concerns/location_concern.rbs +35 -0
- data/sig/aoc_cli/controllers/default_controller.rbs +7 -0
- data/sig/aoc_cli/controllers/event_controller.rbs +18 -0
- data/sig/aoc_cli/controllers/help/event_controller.rbs +11 -0
- data/sig/aoc_cli/controllers/help/puzzle_controller.rbs +13 -0
- data/sig/aoc_cli/controllers/puzzle_controller.rbs +15 -0
- data/sig/aoc_cli/core/attempt_parser.rbs +41 -0
- data/sig/aoc_cli/core/processor.rbs +25 -0
- data/sig/aoc_cli/core/repository.rbs +25 -0
- data/sig/aoc_cli/core/request.rbs +29 -0
- data/sig/aoc_cli/core/resource.rbs +25 -0
- data/sig/aoc_cli/core/stats_parser.rbs +23 -0
- data/sig/aoc_cli/helpers/table_generator.rbs +36 -0
- data/sig/aoc_cli/helpers/view_helper.rbs +15 -0
- data/sig/aoc_cli/models/attempt.rbs +35 -0
- data/sig/aoc_cli/models/event.rbs +17 -0
- data/sig/aoc_cli/models/location.rbs +19 -0
- data/sig/aoc_cli/models/progress.rbs +21 -0
- data/sig/aoc_cli/models/puzzle.rbs +27 -0
- data/sig/aoc_cli/models/puzzle_dir_sync_log.rbs +11 -0
- data/sig/aoc_cli/models/stats.rbs +53 -0
- data/sig/aoc_cli/presenters/attempt_presenter.rbs +13 -0
- data/sig/aoc_cli/presenters/puzzle_presenter.rbs +19 -0
- data/sig/aoc_cli/presenters/stats_presenter.rbs +19 -0
- data/sig/aoc_cli/processors/event_initialiser.rbs +26 -0
- data/sig/aoc_cli/processors/progress_syncer.rbs +29 -0
- data/sig/aoc_cli/processors/puzzle_dir_synchroniser.rbs +40 -0
- data/sig/aoc_cli/processors/puzzle_initialiser.rbs +41 -0
- data/sig/aoc_cli/processors/puzzle_refresher.rbs +21 -0
- data/sig/aoc_cli/processors/resource_attacher.rbs +16 -0
- data/sig/aoc_cli/processors/solution_poster.rbs +34 -0
- data/sig/aoc_cli/processors/stats_initialiser.rbs +15 -0
- data/sig/aoc_cli/processors/stats_refresher.rbs +19 -0
- data/sig/aoc_cli/validators/collection_type_validator.rbs +24 -0
- data/sig/aoc_cli/validators/event_year_validator.rbs +19 -0
- data/sig/aoc_cli/validators/included_validator.rbs +11 -0
- data/sig/aoc_cli/validators/integer_validator.rbs +15 -0
- data/sig/aoc_cli/validators/path_validator.rbs +17 -0
- data/sig/aoc_cli/validators/type_validator.rbs +22 -0
- data/sig/aoc_cli.rbs +6 -0
- data/sig/http.rbs +3 -0
- data/sig/kangaru.rbs +5 -0
- data/sig/nokogiri.rbs +3 -0
- data/sig/reverse_markdown.rbs +3 -0
- metadata +149 -34
- data/.gitignore +0 -5
- data/bin/aoc +0 -4
- data/bin/console +0 -15
- data/bin/setup +0 -7
- data/lib/aoc_cli/commands.rb +0 -232
- data/lib/aoc_cli/database.rb +0 -224
- data/lib/aoc_cli/day.rb +0 -124
- data/lib/aoc_cli/db/reddit.db +0 -0
- data/lib/aoc_cli/errors.rb +0 -275
- data/lib/aoc_cli/files.rb +0 -163
- data/lib/aoc_cli/help.rb +0 -77
- data/lib/aoc_cli/interface.rb +0 -81
- data/lib/aoc_cli/paths.rb +0 -101
- data/lib/aoc_cli/solve.rb +0 -104
- data/lib/aoc_cli/tables.rb +0 -138
- data/lib/aoc_cli/tools.rb +0 -120
- data/lib/aoc_cli/year.rb +0 -116
- data/sample/aoc.rc +0 -21
data/README.md
CHANGED
|
@@ -1,71 +1,39 @@
|
|
|
1
|
-
# `
|
|
1
|
+
# `aoc-cli`
|
|
2
2
|
|
|
3
|
-
|
|
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
|
|
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
|
-
-
|
|
47
|
-
-
|
|
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
|
-
|
|
25
|
+
Install `aoc_cli` with the following command
|
|
57
26
|
|
|
58
27
|
```bash
|
|
59
|
-
|
|
60
|
-
$ cd aoc-cli
|
|
61
|
-
$ rake build install
|
|
28
|
+
gem install aoc_cli
|
|
62
29
|
```
|
|
63
30
|
|
|
31
|
+
|
|
64
32
|
## Setup
|
|
65
33
|
|
|
66
|
-
###
|
|
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
|
-
|
|
82
|
-
|
|
83
|
-
|
|
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
|
-
|
|
92
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
65
|
+
`aoc-cli` is designed to run in a file-tree generated by the application.
|
|
128
66
|
|
|
129
|
-
|
|
67
|
+
There are two types of directories
|
|
130
68
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
```
|
|
69
|
+
1. Event directories
|
|
70
|
+
- These contain puzzle subdirectories
|
|
134
71
|
|
|
135
|
-
|
|
72
|
+
2. Puzzle subdirectories
|
|
73
|
+
- These contain puzzles, input and your soution code
|
|
136
74
|
|
|
137
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
101
|
+
aoc event init <YEAR>
|
|
170
102
|
```
|
|
171
103
|
|
|
172
|
-
This will
|
|
173
|
-
|
|
174
|
-
```bash
|
|
175
|
-
aoc -y 2020 -u $alias
|
|
176
|
-
```
|
|
104
|
+
This will:
|
|
177
105
|
|
|
178
|
-
|
|
106
|
+
- Fetch your latest stats and setup your progress
|
|
107
|
+
- Create an event directory
|
|
179
108
|
|
|
180
|
-
|
|
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
|
-
|
|
112
|
+
### Initialising a Puzzle
|
|
185
113
|
|
|
186
|
-
|
|
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
|
-
|
|
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
|
|
120
|
+
aoc puzzle init <DAY>
|
|
192
121
|
```
|
|
193
122
|
|
|
194
123
|
This command performs the following actions
|
|
195
124
|
|
|
196
|
-
- Creates a
|
|
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
|
-
|
|
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
|
-
|
|
132
|
+
### Solving Puzzles
|
|
206
133
|
|
|
207
|
-
From the
|
|
134
|
+
From the puzzle subdirectory you can solve puzzles by running the command
|
|
208
135
|
|
|
209
136
|
```bash
|
|
210
|
-
aoc
|
|
137
|
+
aoc puzzle solve --answer <ANSWER>
|
|
211
138
|
```
|
|
212
139
|
|
|
213
|
-
You will then receive one of
|
|
140
|
+
You will then receive one of three responses
|
|
214
141
|
|
|
215
|
-
1. The answer
|
|
216
|
-
2. The answer
|
|
217
|
-
3. You have
|
|
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
|
|
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
|
-
|
|
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
|
|
234
|
-
|
|
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
|
-

|
|
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
|
-
###
|
|
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
|
-
|
|
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
|
|
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
|
-

|
|
276
|
-
|
|
277
171
|
### Progress
|
|
278
172
|
|
|
279
|
-
To view your progress in the year you can run the
|
|
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
|
|
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
|
-

|
|
294
|
-
|
|
295
|
-
## Reddit Integration
|
|
296
|
-
|
|
297
|
-

|
|
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
|
-
|
|
182
|
+
## Help
|
|
316
183
|
|
|
317
|
-
|
|
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
|
-
|
|
187
|
+
## Contributing
|
|
322
188
|
|
|
323
|
-
|
|
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
|
-
|
|
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
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
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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 = %w[lib db]
|
|
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,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
|