Revising this issue instead of opening a new one, please ignore the Old part.
Revised
Allow for a configurable workspace
folder. Started a discussion for the config interface on #61
Allow for saving solution with these goals:
- Atomic: the solution should be runnable without having to fetch the original clash json
- Human-readable: A user who remembers a clash solved in the past should be able to navigate the workspace and find it easily
- Multiple: The workspace should be able to organize multiple solutions for a puzzle
- Notable: A user should be able to save a solution with a particular in order to cleanly differentiate solutions of a single exercise
Have a command (temporarily solve
) which
- creates
workspace/{clash-slug}/{lang}_{name}/
(lets call this folder $soldir
)
- creates
clash gen {lang} > "$soldir/solution.{lang extension}"
- copies the current clash's json to
$soldir/puzzle.json
Have a command (temporarily commit
) which
- saves the current solution with a name the user provides
- copies the current solution into a new
$soldir
to allow quick iteration
Make runner commands context-sensitive:
- If you run
clash run
(or a new porcelain command #60) from inside a $soldir
it should auto detect puzzle.json
and run the tests against it
- This would make it more convenient for users with integrated terminals in their editors
Slugging clashes and caching JSON
I think the public handle is unreadable as a folder name, it would be better if we slugged the title of the clash.
The rationale behind copying the clash JSON is to make this feature independent of codingame.tools and codingame.com. As long you have this binary and $soldir
, you can still solve the puzzle.
Folder structure
I am personally against making a subfolder for each language, I feel like if the language is relevant to the solution it can be part of the solution name (if we name solutions by default like rust_1
, js_1
, js_2
, etc.).
Plus, this tool is flexible enough to allow for solutions that use multiple language (say javascript + webassembly text) solutions.
Old:
Keep every solution in its own folder inside a folder for the clash:
- solutions/
- {CLASH_ID}/
- {timestamp}_{custom_solution_name}/
- .git/
- sol.rs
- language # => rust
- {timestamp}/ # solution without name
- .git/
- sol.py
- language # => python
then allow for browsing solutions sorted by the timestamp with
clash solutions [CLASH_ID]
which would present the user with a select or fzf with the list of solutions for the clash of provided id or current clash if there is no id.
Selecting a solution should open it in the default editor.
Scenarios when I think it would be appropriate to create a new solution
- When the clash is changed with
clash next
or some other command there should be a flag that tells clash run
to create a new solution automatically
- With a
clash save <name>
command which should save a new solution no matter what and set that solution as the current one being tested
- With a
clash solve
command
Scenarios when I think it would be appropriate to git add
and git commit
inside a solution:
- When a solution is edited and then tested with
clash run
, there could be a commit with the PASS/FAIL test status