Coder Social home page Coder Social logo

Comments (12)

derberg avatar derberg commented on July 28, 2024 2

I very much like kubectl and not having actions as flags, have a look at https://kubernetes.io/docs/reference/kubectl/cheatsheet/#kubectl-context-and-configuration

asyncapi config get-contexts                          # display list of files in the context of the CLI
asyncapi config current-context                     # display the name of the file that is currently a context of the CLI
asyncapi config use-context myasyncapi

thoughts?

from cli.

Souvikns avatar Souvikns commented on July 28, 2024 1

I was thinking about the commands for setting the context and then also overriding it if the user wants. @derberg do let me know what you think about this -

To set, update and delete the context

asyncapi context --set <specPath | URL> set or update the context 
asyncapi context --remove clear the context 

To override the context or to use a temporary context we can have a --spec flag which would be a root level option.

asyncapi --spec=file/path/or/url generate <template>

from cli.

derberg avatar derberg commented on July 28, 2024 1

except for setting and removing, user also needs a way to list all (to know which one to set) and to check what is the current.

the best would be to save the context file as .asyncapi in the "home" of the user, so where all files like .npm, .docker, .bash_profile and others. It is the best place because long term we need to make sure npm is not needed to install the CLI and should check out possibilities to publish it on managers like brew

from cli.

Souvikns avatar Souvikns commented on July 28, 2024 1

use will be only for using existing one, set` will be for setting a new one (and automatically set as current). Makes sense?

ok, got it. 👍🏻

from cli.

derberg avatar derberg commented on July 28, 2024 1

@Souvikns I think it is about time. Just consider as small PRs as possible to make review and merge process easy, so not all commands at start.

also current --context flag will need to be fixed as now it points to a file and not context name, we just need another --file flag

from cli.

Souvikns avatar Souvikns commented on July 28, 2024

I very much like kubectl and not having actions as flags, have a look at https://kubernetes.io/docs/reference/kubectl/cheatsheet/#kubectl-context-and-configuration

asyncapi config get-contexts                          # display list of files in the context of the CLI
asyncapi config current-context                     # display the name of the file that is currently a context of the CLI
asyncapi config use-context myasyncapi

thoughts?

Yeah, this is better, it's clear to understand.

So instead of flags, we use commands like

asyncapi context set <path|URL>
asyncapi context remove

So if context is a command then set and remove is an argument. Still, I guess we should have a flag if the user wants to override the context in any case.


One thing I would like to clarify, about saving the context. As we will be saving the <filePath | URL> of the spec file.
Most users will install CLI globally where they might have different projects that are using async API spec file for their development. If we have a single context then the user has to change/update the context every time he switches from one workspace to another. @derberg what do you think, we should do for this scenario.

  • One thing we can do is to let users save context in key-value pair where they can switch easily.
  • We save the context in a key-value pair from where the context set command was called. then the user doesn't have to update the context every time he opens a new folder.

from cli.

Souvikns avatar Souvikns commented on July 28, 2024

@derberg to sum up, how about these commands for the context.

asyncapi context set <context-name> <filePath | URL>   | set context 
asyncapi context current                               | get the current set context 
asyncapi context list                                  | list all the contexts 
asyncapi context remove                                | remove the current set context

from cli.

derberg avatar derberg commented on July 28, 2024

if I want to switch from context A to B, would I use set? or we probably need use, right? this is how I have it in nvm, I do nvm use <node version> after listing what I have

from cli.

Souvikns avatar Souvikns commented on July 28, 2024

Yeah, use makes much more sense, but if use is changing the set context should we have another command for creating a new context value to be saved in the .asyncapi file, or use command will update/create a new context accordingly

from cli.

derberg avatar derberg commented on July 28, 2024

use will be only for using existing one, set will be for setting a new one (and automatically set as current). Makes sense?

from cli.

Souvikns avatar Souvikns commented on July 28, 2024

@derberg shall I start working on this issue 😊.

from cli.

asyncapi-bot avatar asyncapi-bot commented on July 28, 2024

🎉 This issue has been resolved in version 0.2.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

from cli.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.