Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Editor mode implemented #69

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open

Editor mode implemented #69

wants to merge 7 commits into from

Conversation

DK318
Copy link
Member

@DK318 DK318 commented Apr 11, 2022

Description

An [-e|--edit] implementation. It opens a temporary file where you see TOML-like representation of an entry.
Also, I've made entry path in CreateOptions parser optional argument.

Related issue(s)

No related issues.

✅ Checklist for your Pull Request

Related changes (conditional)

  • Tests
    • If I added new functionality, I added tests covering it.
    • If I fixed a bug, I added a regression test to prevent the bug from
      silently reappearing again.
  • Documentation
    • I checked whether I should update the docs and did so if necessary:
  • Public contracts
    • Any modifications of public contracts comply with the Evolution
      of Public Contracts
      policy.
    • I added an entry to the changelog if my changes are visible to the users
      and
    • provided a migration guide for breaking changes if possible

Stylistic guide (mandatory)

dcastro and others added 6 commits April 22, 2022 23:18
Problem: at this moment we use our own format in editor mode.
Reinventing the wheel can be hard and time consuming.

Solution: changed this format to `TOML`.
Problem: at this moment `entry path` is required argument.
Sometimes we don't want to specify entry path in editor mode
while creating entry.

Solution: made `entry path` in `create` command optional argument.
Problem: `tomland` is bugging on non-ascii characters and
`toml` spec doesn't support some escape sequences like `\NUL` or `\DEL`.

Solution: rollbacked on our homebrewed editor file format and added
tags support.
Problem: after changes in editor mode unit and property tests
are not compiling. Moreover, they are outdated.

Solution: updated these tests.
@DK318 DK318 force-pushed the diogo/editor-mode branch from 904796a to be67a10 Compare April 25, 2022 15:01
@DK318 DK318 changed the title [WIP] Editor mode implemented Editor mode implemented Apr 25, 2022
@DK318 DK318 marked this pull request as ready for review April 25, 2022 15:06
@DK318 DK318 requested review from dcastro and MagicRB April 26, 2022 10:50
@dcastro dcastro requested a review from sancho20021 May 3, 2022 12:27
Copy link
Contributor

@sancho20021 sancho20021 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently, the only option to abort creating an entry using editor mode is to somehow kill the terminal. Could we have another way to abort the creation? Maybe by putting special line in the beginning of the file or clearing the file totally.

> pw 1234
> # ^
> # unexpected '1'
> # expecting '=' or white space
-}
annotateParseErrors :: [ParseError] -> [AnnotatedLine] -> [AnnotatedLine]
annotateParseErrors errors lines = foldl' annotateParseError lines errors
annotateEditorFile :: ParseErrorBundle Text Void -> Text -> [AnnotatedLine]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When user tries to save incorrect file multiple times, the same error description appends to the end of the existing one.
Example:

BAD_FORMAT
[tags]
#^
# unexpected "[t"
# expecting "=~" or '='
#^
# unexpected "[t"
# expecting "=~" or '='

Maybe we could avoid this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants