Suggestion: Lets improve 'snapcraft init' command

Hi,

As discussed in #snappy I suggest to change the way that ‘snapcraft init’ works so that it becomes more flexible and a bit simpler to use. In short, make it behave more like ‘git init’.

Current work flow for creating a new snap named e.g. tio:

$ mkdir tio
$ cd tio
$ snapcraft init

Suggested behaviour (saves 1 step):

$ snapcraft init tio
$ cd tio

The weakness of the current behaviour becomes maybe clearer when starting out preparing to create multiple snaps:

$ mkdir tio
$ cd tio
$ snapcraft init
$ cd ..

$ mkdir firefox
$ cd firefox
$ snapcraft init
$ cd ..

$ mkdir nano
$ cd nano
$ snapcraft init
$ cd ..

Vs.:

$ snapcraft init tio
$ snapcraft init firefox
$ snapcraft init nano

Also, in combination with the suggestion of consolidating all the temporary build directories under one “build” directory (see https://forum.snapcraft.io/t/suggestion-lets-consolidated-temporary-build-directories-under-one-directory-build), I suggest we simply do away with the snap subdirectory so that users get one level closer to what matters to them and also to minimize the confusion of what a “snap” is. This way e.g. ‘snapcraft init tio’ only creates the named snap directory tio and populates it with the template snapcraft.yaml file.

Meaning, move away from the current structure, illustrated by this example:

tio
├── parts
├── prime
├── snap
│   ├── gui
│   │   └── icon.png
│   └── snapcraft.yaml
├── stage
└── tio_1.27_amd64.snap

To this:

tio
├── build
│   ├── parts
│   ├── prime
│   └── stage
├── gui
│   └── icon.png
├── snapcraft.yaml
└── tio_1.27_amd64.snap
2 Likes