func icon indicating copy to clipboard operation
func copied to clipboard

Streamline `func create` for newcomers

Open salaboy opened this issue 3 years ago • 11 comments

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

salaboy avatar Jul 06 '22 08:07 salaboy

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.

lance avatar Jul 06 '22 16:07 lance

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

grafvonb avatar Sep 16 '22 17:09 grafvonb

/assign @grafvonb

grafvonb avatar Sep 16 '22 17:09 grafvonb

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

grafvonb avatar Sep 16 '22 18:09 grafvonb

@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 avatar Oct 06 '22 19:10 lance

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.

lance avatar Oct 06 '22 19:10 lance

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.

github-actions[bot] avatar Jan 05 '23 01:01 github-actions[bot]

/remove-lifecycle stale

zroubalik avatar Jan 05 '23 09:01 zroubalik

@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!

Sanket-0510 avatar Feb 19 '24 18:02 Sanket-0510

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.

github-actions[bot] avatar May 20 '24 01:05 github-actions[bot]

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.

github-actions[bot] avatar Aug 30 '24 01:08 github-actions[bot]