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

refactor repl commands, add :help command #230

Merged
merged 2 commits into from
Jul 7, 2020
Merged

Conversation

bookshelfdave
Copy link
Collaborator

@bookshelfdave bookshelfdave commented Jul 6, 2020

GADT/typed indices implementation from @byorgey via #229

  • decide on :help output
  • add test for :help

see also:

longHelp = "",
category = Dev,
cmdtype = ShellCmd,
action = handleAnn,
Copy link
Member

Choose a reason for hiding this comment

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

I no longer see any benefit to separating out the definition of the actions like this. It just means the code for each command is spread out over multiple parts of the file. At the very least I think we should move the definition of each action to right after the definition of its REPLCommand, so all the code for each command will be in one place.

category = Dev,
cmdtype = ShellCmd,
action = handleTypeCheck,
parser = TypeCheck <$> parseTypeTarget
Copy link
Member

Choose a reason for hiding this comment

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

Can we also move the definition of parseTypeTarget to right here? Unless I am mistaken this is the only place it is used.

iputStrLn ""
where
sortedList cmds = sortBy (\(SomeCmd x) (SomeCmd y) -> compare (name x) (name y)) $ filteredCommands cmds
-- remove "builtins" (let, eval, etc), don't show dev-only commands by default
Copy link
Member

Choose a reason for hiding this comment

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

It would be nice if we could find a good way to show built-in commands too, though I think that can probably be put off to the future.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@byorgey I added build-in commands to the help output.

Copy link
Member

Choose a reason for hiding this comment

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

Great!

usingCmd =
REPLCommand {
name = "using",
helpcmd = ":using <extension>",
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't have a colon in front of :using.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fixed, is using a dev-only command?

Copy link
Member

Choose a reason for hiding this comment

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

No, using is for end users to turn on language extensions.

@@ -91,342 +91,321 @@ annCmd :: REPLCommand 'CAnn
annCmd =
REPLCommand {
name = "ann",
helpcmd = ":ann",
Copy link
Member

Choose a reason for hiding this comment

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

I like the idea of having a helpcmd field. However, let's not put explicit tab characters in them --- both because we should avoid using tabs in the output (different terminals etc. may display them differently) and also because it's fragile. Instead let's make the code to display the help more general, so it figures out the maximum length of all the helpcmd fields it's being asked to display, and pads things out with spaces approriately.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

agreed on tabs, I'll push another change to this PR soonish.

@bookshelfdave
Copy link
Collaborator Author

bookshelfdave commented Jul 6, 2020

@byorgey removed tabs, padding :help columns with strings

GADT/typed indices implementation from byorgey via #229
@@ -0,0 +1,2 @@
:help
1+1
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Restyled.io wants to strip the whitespace after the :help command, so I added a simple 1+1 to produce additional output.

@byorgey byorgey merged commit 5c82408 into master Jul 7, 2020
@byorgey
Copy link
Member

byorgey commented Jul 7, 2020

Looks good to me!

@byorgey byorgey mentioned this pull request Jul 16, 2020
@byorgey byorgey deleted the dp_help_command branch May 27, 2021 16:33
@byorgey byorgey mentioned this pull request May 27, 2021
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.

2 participants