Skip to content

refactor repl commands, add :help command - #230

Merged
byorgey merged 2 commits into
masterfrom
dp_help_command
Jul 7, 2020
Merged

byorgey merged 2 commits into
masterfrom
dp_help_command

Conversation

@bookshelfdave

@bookshelfdave bookshelfdave commented Jul 6, 2020 •

Copy link
Copy Markdown
Collaborator

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
Copy Markdown
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.

Comment thread src/Disco/Interactive/Commands.hs Outdated
category = Dev,
cmdtype = ShellCmd,
action = handleTypeCheck,
parser = TypeCheck <$> parseTypeTarget

Copy link
Copy Markdown
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.

Comment thread src/Disco/Interactive/Commands.hs Outdated
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Member

Choose a reason for hiding this comment

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

Great!

Comment thread src/Disco/Interactive/Commands.hs Resolved
Comment thread src/Disco/Interactive/Commands.hs Outdated
usingCmd =
REPLCommand {
name = "using",
helpcmd = ":using <extension>",

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

Comment thread src/Disco/Interactive/Commands.hs Resolved
annCmd =
REPLCommand {
name = "ann",
helpcmd = ":ann",

Copy link
Copy Markdown
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
Copy Markdown
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

bookshelfdave commented Jul 6, 2020 •

Copy link
Copy Markdown
Collaborator Author

@byorgey removed tabs, padding :help columns with strings

GADT/typed indices implementation from byorgey via #229
Comment thread test/repl-help/input
@@ -0,0 +1,2 @@
:help
1+1

Copy link
Copy Markdown
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

byorgey commented Jul 7, 2020

Copy link
Copy Markdown
Member

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