New snapcraft CLI

snapcraft has had many complaints about how the help output from the cli is really overwhelming, with that in mind a few months ago (October) I started a quick prototype for which I never got time to finish as new commands were being added constantly into snapcraft at that time. That is all in the past now and this cycle we have decided to focus on the command line interface and clean it up a bit… this is a small peek at what it will look like:

sergiusens@mirkwood:~/source/snapcraft$ python3 -m snapcraft.cli --help
Usage: __main__.py [OPTIONS] COMMAND [ARGS]...

Options:
  --help  Show this message and exit.

Commands:
  close         Close <channel> for <snap-name>.
  create-key    Create a key to sign assertions.
  history       Get the history on the store for <snap-name>.
  list-keys     List the keys available to sign assertions.
  push          Push <snap-file> to the store.
  register      Register <snap-name> with the store.
  register-key  Register a key with the store to sign...
  release       Release <snap-name> on <revision> to the...
  snap
  status        Get the status on the store for <snap-name>.
sergiusens@mirkwood:~/source/snapcraft$ python3 -m snapcraft.cli status --help
Usage: __main__.py status [OPTIONS] <snap-name>

  Get the status on the store for <snap-name>.

  Examples:
      snapcraft status my-snap
      snapcraft status my-snap --arch armhf

Options:
  --arch <arch>      The snap architecture to get the status for
  --series <series>  The snap series to get the status for
  --help             Show this message and exit.
sergiusens@mirkwood:~/source/snapcraft$ python3 -m snapcraft.cli status telegram-sergiusens
Track    Arch    Channel    Version    Revision
latest   amd64   stable     1.0.29     32
                 candidate  ^          ^
                 beta       ^          ^
                 edge       1.0.29     32

This is going to look pretty similar to the cli for the snap command. For comparison, here it is:

sergiusens@mirkwood:~/source/snapcraft$ snap --help 
Usage:
  snap [OPTIONS] <command>

Install, configure, refresh and remove snap packages. Snaps are
'universal' packages that work across many different Linux systems,
enabling secure distribution of the latest apps and utilities for
cloud, servers, desktops and the internet of things.

This is the CLI for snapd, a background service that takes care of
snaps on the system. Start with 'snap list' to see installed snaps.


Application Options:
      --version  Print the version and exit

Help Options:
  -h, --help     Show this help message

Available commands:
  abort       Abort a pending change
  ack         Adds an assertion to the system
  alias       Enables the given aliases
  aliases     Lists aliases in the system
  buy         Buys a snap
  change      List a change's tasks
  changes     List system changes
  connect     Connects a plug to a slot
  disable     Disables a snap in the system
  disconnect  Disconnects a plug from a slot
  download    Downloads the given snap
  enable      Enables a snap in the system
  find        Finds packages to install
  get         Prints configuration options
  help        Help
  info        show detailed information about a snap
  install     Installs a snap to the system
  interfaces  Lists interfaces in the system
  known       Shows known assertions of the provided type
  list        List installed snaps
  login       Authenticates on snapd and the store
  logout      Log out of the store
  refresh     Refreshes a snap in the system
  remove      Removes a snap from the system
  revert      Reverts the given snap to the previous state
  run         Run the given snap command
  set         Changes configuration options
  try         Tests a snap in the system
  unalias     Disables the given aliases
  version     Help
  watch       Watch a change in progress
sergiusens@mirkwood:~/source/snapcraft$ snap install --help 
Usage:
  snap [OPTIONS] install [install-OPTIONS] <snap>...

The install command installs the named snap in the system.

Application Options:
      --version              Print the version and exit

Help Options:
  -h, --help                 Show this help message

[install command options]
          --channel=         Use this channel instead of stable
          --edge             Install from the edge channel
          --beta             Install from the beta channel
          --candidate        Install from the candidate channel
          --stable           Install from the stable channel
          --devmode          Put snap in development mode and disable security
                             confinement
          --jailmode         Put snap in enforced confinement mode
          --classic          Put snap in classic mode and disable security
                             confinement
          --revision=        Install the given revision of a snap, to which you
                             must have developer access
          --dangerous        Install the given snap file even if there are no
                             pre-acknowledged signatures for it, meaning it was
                             not verified and could be dangerous (--devmode
                             implies this)
1 Like

Glad to see this moving forward, thanks @sergiusens!

The working is happening here https://github.com/snapcore/snapcraft/pull/1307

1 Like

You can now try the new functionality by installing it from the stable/new-cli branch

sudo snap install snapcraft --channel stable/new-cli --classic
5 Likes