Defines a new sftp file system configuration or edits an old one with the same id.
        Usage: sftpman setup {options}
        Available {options}:
            --id={unique system identifier}
                You use this to recognize and manage this sftp system.
                It determines what the local mount point is.
                If `--id=example`, the filesystem will be mounted to: `/mnt/sshfs/example`
            --host={host to connect to}
            --port={port to connect to} [default: 22]
            --user={username to authenticate with}
            --mount_opt={option to pass to sshfs} [optional] [can be passed more than once]
                Example: --mount_opt="follow_symlinks" --mount_opt="workaround=rename"
                `sshfs --help` tells you what sshfs options are available
            --mount_point={remote path to mount}
            --auth_method={method}
                Specifies the authentication method.
                Can be `password`, `publickey`, `hostbased`, `keyboard-interactive` or `gssapi-with-mic`. [default: publickey]
            --ssh_key={path to the ssh key to use for authentication}
                Only applies if auth_method is `publickey`.
            --cmd_before_mount={command to run before mounting} [default: /bin/true]
                Allows you to run a custom command every time this system is mounted.

def command_setup(self, *args):
        """Defines a new sftp file system configuration or edits an old one with the same id.
        Usage: sftpman setup {options}
        Available {options}:
            --id={unique system identifier}
                You use this to recognize and manage this sftp system.
                It determines what the local mount point is.
                If `--id=example`, the filesystem will be mounted to: `/mnt/sshfs/example`
            --host={host to connect to}
            --port={port to connect to} [default: 22]
            --user={username to authenticate with}
            --mount_opt={option to pass to sshfs} [optional] [can be passed more than once]
                Example: --mount_opt="follow_symlinks" --mount_opt="workaround=rename"
                `sshfs --help` tells you what sshfs options are available
            --mount_point={remote path to mount}
            --auth_method={method}
                Specifies the authentication method.
                Can be `password`, `publickey`, `hostbased`, `keyboard-interactive` or `gssapi-with-mic`. [default: publickey]
            --ssh_key={path to the ssh key to use for authentication}
                Only applies if auth_method is `publickey`.
            --cmd_before_mount={command to run before mounting} [default: /bin/true]
                Allows you to run a custom command every time this system is mounted.
        """
        def usage():
            print(self.command_setup.__doc__)
            sys.exit(1)

        if len(args) == 0:
            usage()

        try:
            # All of these (except mount_opt) map directly to the model properties
            # We allow several `mount_opt` flags and merge their values, before
            # assigning to the `mount_opts` property (which expects a list).
            fields = [
                "id", "host", "port", "user",
                "mount_opt", "mount_point",
                "ssh_key", "cmd_before_mount",
                "auth_method",
            ]
            opts, _ = getopt.getopt(args, "", ["%s=" % s for s in fields])
        except getopt.GetoptError as e:
            sys.stderr.write('Error: %s\n\n' % e)
            usage()

        system = SystemModel()
        mount_opts = []
        for name, value in opts:
            name = name.lstrip('-')
            if not hasattr(system, name):
                continue
            if name == 'mount_opt':
                mount_opts.append(value)
                continue
            setattr(system, name, value)
        system.mount_opts = mount_opts

        is_valid, errors = system.validate()
        if not is_valid:
            sys.stderr.write('Invalid data found:\n')
            for field_name, msg in errors:
                sys.stderr.write(' - %s: %s\n' % (field_name, msg))
            sys.stderr.write('\n')
            usage()
            sys.exit(1)

        system.save(self.environment)
        print('Configuration created.')
        print('You can try mounting now: `sftpman mount %s`' % system.id)