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

Turn CLI messages to constants #21

Closed
Souvikns opened this issue Jul 9, 2021 · 9 comments · Fixed by #40
Closed

Turn CLI messages to constants #21

Souvikns opened this issue Jul 9, 2021 · 9 comments · Fixed by #40
Labels

Comments

@Souvikns
Copy link
Member

Souvikns commented Jul 9, 2021

please create another followup issue to turn these messages into constants so we reuse them in components and tests, something like https://github.com/asyncapi/asyncapi-react/blob/master/library/src/constants.ts

no need to fix it now, not related to this pr

Originally posted by @derberg in #14 (comment)

@Souvikns
Copy link
Member Author

@magicmatatjahu shall I start with this issues, next?

@magicmatatjahu
Copy link
Member

magicmatatjahu commented Jul 22, 2021

Loading spec from remote source is more important - #1 (comment) :)

@Souvikns
Copy link
Member Author

asyncapi validate 
No contexts saved yet, run asyncapi --help to know more. 

The help string also does not say what contexts are, so @derberg should we update the help text to talk about the context in a detailed manner or add have a better error message for this scenario?

I think the help message is a general version of all our commands and if we write what is a context there, it could get cluttered so shall we have command level help messages to talk about specific commands. In general, we have to help the user understand how he can pass in spec file to the CLI.
Also as of now, there are 4 main ways to pass the spec file path.

  • --file flag
  • --context flag
  • set an appropriate context then just use any commands
  • have asyncapi.yml file in the working directory.

@derberg
Copy link
Member

derberg commented Jul 27, 2021

We simply need more structured and formated info, if we do it, then it won't get cluttered. Look at help section here https://clig.dev/#help and the jq example.

@Souvikns
Copy link
Member Author

Souvikns commented Jul 27, 2021

Then I guess we can solve this issue by updating the help command or adding a context section in the help string so as to talk about what context does, and how could users benefit from it.

taking inspiration from git

$ asyncapi
usage: asyncapi [--verison] [--help] [--file <spec-file-path>] [--context <saved-context>]
                [--watch] <command> [<args>]

commands:
  validate    validate a specification file
  context     manage context 

To make your commands shorter use context, create and reuse your contexts accordingly 
  current                          check the current context
  list                             list all the saved context 
  remove <context-name>            remove a context from the store
  use <context-name>               set a context as current
  add <context-name> <file-path>   add/update new context

@derberg
Copy link
Member

derberg commented Jul 27, 2021

we need more complex, and contextual help:

  • one thing is what you wrote, have help displayed when running asyncapi as git has
  • another is that we should have help on the command level, dedicated to given command only, like asyncapi context --help
  • and when running asyncapi validate or any other command, and there is no default file or context, we need detailed help message that explains the priority we have, the file flag, context flag, default context and default filename

I think better would be to first refactor help to constants to have simple PR to handle and then in another issue discuss help texts. Let us have as small and focused PRs as possible

@Souvikns
Copy link
Member Author

I think better would be to first refactor help to constants

Does this mean the help string will now be something like this ⬇ where the help string is made up of smaller constants?

const helpString = `
Usage:
  ${USAGE_STRING}
`

@derberg
Copy link
Member

derberg commented Jul 27, 2021

it depends but in short, yes 😄

help shown after calling asyncapi will be a combination of help shown under asyncapi context --help and asyncapi validate --help and others. So you need what you described, basically reuse help text.

In case of messages like <Text>The context you are trying to use is not present.</Text> you need <Text>${CONTEXT_MISING}</Text>; and reuse the same constant value in tests, so any changes to help text doesn't require changes in tests

@asyncapi-bot
Copy link
Contributor

🎉 This issue has been resolved in version 0.3.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging a pull request may close this issue.

4 participants