knative / func

Knative Functions client API and CLI
Apache License 2.0
262 stars 135 forks source link

Streamline `func create` for newcomers #1097

Open salaboy opened 1 year ago

salaboy commented 1 year ago

Currently func create takes a mandatory argument (language) in the shape of a flag. It also requires to be run inside an empty directory (unless you specify the path) which is not optimal or expected by all users.

Mandatory arguments

Currently, the "language" flag is the only mandatory parameter so,

If you type func create on an empty directory you get:

> func create 
Error: Required flag "language" not set.
Available language runtimes are:
  go
  node
  python
  quarkus
  rust
  springboot
  typescript

This doesn't help a newcomer to know what the language flag is, for some people this will mean --language or -l but it might not be clear for everyone. Notice that this is a required parameter hence making this a positional argument might make some sense. In such a case we can make something like this:

>func create

Language is missing, please add the language argument: 
Example: func create <language> choosing one from the following list
Available language runtimes are:
  go
  node
  python
  quarkus
  rust
  springboot
  typescript

Checking the func create --help, it shows an example that is not working:

 o Create a Node.js Function in the directory 'myfunc'.
          $ func create myfunc

Directory creation

Creating or not creating a directory for the function is a controversial topic that, in my opinion, we need to fix. If we follow the git, npm or even go mod approach you are always working in a directory where your project will live. For these cases, the user needs to create a directory. Current func create checks if the user is in an empty directory to create a function if the name of the function is not provided as the last argument, in which case it creates a directory.

For example:

func create -l go func3
Created go Function in /tmp/func3

Created a directory and a function inside it.

For this one I have mixed feelings, as we should decide if we create or not create directories with func, supporting both in my opinion causes confusion.

if we change [path] to be a flag, it will make more sense for cases where a CI tool is running create, so we don't loose the functionality.

Open Questions

Do you have any other categories of things to improve for func create ? Any other thoughts or ideas? @lance @lkingland @zroubalik @matejvasek

lance commented 1 year ago

We have talked in the past about entering "confirm" mode when a user types simply func create with no flags/parameters. See https://github.com/knative-sandbox/kn-plugin-func/issues/573#issuecomment-1017995470

Personally, I like this a lot.

grafvonb commented 1 year ago

I'll take over the task: enter "confirm" mode after func create; as proposed above.

grafvonb commented 1 year ago

/assign @grafvonb

grafvonb commented 1 year ago

@lance @salaboy Could you clearly state what is the scope to implement for this issue? I think I have mixed it with #573...

lance commented 1 year ago

@grafvonb we talked a little about this in the working group meeting. It's not very clearly laid out, and could benefit from coordination between this issue and a few others - or it could be closed as a duplicate. @salaboy do you want to chime in here?

lance commented 1 year ago

Looking closer at old comments and such, I think this is almost certainly a duplicate of #573 but will let @salaboy and @lkingland chime in.

github-actions[bot] commented 1 year ago

This issue is stale because it has been open for 90 days with no activity. It will automatically close after 30 more days of inactivity. Reopen the issue with /reopen. Mark the issue as fresh by adding the comment /remove-lifecycle stale.

zroubalik commented 1 year ago

/remove-lifecycle stale

Sanket-0510 commented 4 months ago

@lkingland after going through each comment, my question is what shall be the final design for this? I mean shall we put user in the confirm mode triggering func create -c or shall we build fully interactive func create command. Cause right now we are not doing any of them!

github-actions[bot] commented 1 month ago

This issue is stale because it has been open for 90 days with no activity. It will automatically close after 30 more days of inactivity. Reopen the issue with /reopen. Mark the issue as fresh by adding the comment /remove-lifecycle stale.