mission-control-contracts

    Shared Mission Control commands for the CLI, the web UI and the desktop shell

    mission-control
    contract
    cli
    Download zip
    Author
    Version
    0.5.0
    License
    Apache-2.0
    Last updated
    2 hours ago
    Downloads
    193

    #moonrockz/mission-control-contracts

    Shared commands for the Mission Control CLI, the Rabbita web UI and the Proton desktop shell.

    moon add moonrockz/mission-control-contracts

    version() gives the workspace version as a Version value (three integer parts; Version::Version(text) raises VersionError for any other text). Commands form a tree. help, version, web, status, stop and serve are single words. The other commands are a noun and a verb:

    PathValue
    kb validateKb(Validate)
    kb rules list, show, check, testKb(Rules(List)), ...
    kb profiles list, showKb(Profiles(List)), ...
    config showConfig(Show)
    project add, remove, list, showProject(Add), ...

    Command::Command(path) reads a path such as kb validate, or an alias such as --version. Command::parse(args) reads the command at the start of the arguments and returns it with the arguments that follow it. Both raise CommandError::UnknownCommand with the words that were read (kb nope), or CommandError::MissingVerb with the Noun when the words stop after a noun (kb).

    Each command gives its path (path() and path_text()), its noun (noun()), its Proton command ID (proton_id(): the path joined with ., such as mission-control.version or mission-control.kb.validate) and its help line (description()). commands lists every command and nouns lists the top-level nouns, in help order. Noun::commands() lists the commands of one noun.

    Channel::current() gives the channel of the build: Stable, Insiders or Nightly. A build from the repository is Stable. Channel::name() gives the name, such as stable.

    #App commands

    The package moonrockz/mission-control-contracts/app has one typed definition of each command and event that the server, the web UI, the CLI and the desktop app exchange. The definitions use moonbit-community/proton_contract.

    CommandRequestReply
    app_infoEmptyRequestAppInfo
    list_projectsEmptyRequestArray[Project]
    add_projectAddProjectAddedProject
    open_projectProjectIdProject
    remove_projectProjectIdProject
    show_projectShownProjectProject
    stop_appEmptyRequestStopping
    choose_folderEmptyRequestChosenFolder

    EventPayload
    projects_changedArray[Project]
    project_shownShownProject
    app_stoppingStopping

    The server has each command in server_commands. Only the window of the desktop app has choose_folder. wire_name(name) gives the name between the server and a view, such as app:add_project.

    These types have rules. Their constructors raise a typed error, and reading them from JSON uses the same rules:

    TypeRuleJSON
    InstanceName1 to 32 lower-case letters, digits and hyphens, with a letter at the start"review-42"
    ProjectIdA whole number from 13
    UnixMillisMilliseconds since 1970, from 0"1764720000000"

    The JSON form of an enum is its name in lower case, such as "desktop" or "already_listed". A field without a value is absent. When a value is read, the field can also be null.

    CommandError

    pub(all) suberror CommandError {
    UnknownCommand(String)
    MissingVerb(Noun)
    } derive(Eq,
    Debug
    )

    Raised when a text names no command.

    CommandError::equal

    automatically derived

    CommandError::not_equal

    fn CommandError::not_equal(x : CommandError, y : CommandError) -> Bool
    automatically derived

    CommandError::to_repr

    automatically derived

    VersionError

    pub(all) suberror VersionError {
    InvalidVersion(String)
    } derive(Eq,
    Debug
    )

    Raised when a text is not a version.

    VersionError::equal

    automatically derived

    VersionError::not_equal

    fn VersionError::not_equal(x : VersionError, y : VersionError) -> Bool
    automatically derived

    VersionError::to_repr

    automatically derived

    Channel

    pub(all) enum Channel {
    Stable
    Insiders
    Nightly
    } derive(Eq,
    Debug
    )

    How a build is published.
    impl ToJson for Channel

    Channel::current

    fn Channel::current() -> Channel

    The channel of this build. A build from the repository is Stable.

    Channel::equal

    fn Channel::equal(Channel, Channel) -> Bool
    automatically derived

    Channel::name

    fn Channel::name(self : Channel) -> String

    The name of the channel: stable, insiders or nightly.

    Channel::not_equal

    fn Channel::not_equal(x : Channel, y : Channel) -> Bool
    automatically derived

    Channel::to_json

    The JSON form of a channel is its name.

    Channel::to_repr

    automatically derived

    Command

    pub(all) enum Command {
    Help
    Version
    Kb(KbCommand)
    Config(ConfigCommand)
    Project(ProjectCommand)
    Web
    Desktop
    Status
    Stop
    Serve
    } derive(Eq,
    Debug
    )

    A command the CLI, the web UI and the desktop shell all understand. A command is a single word, such as version, or a noun and a verb, such as kb validate.

    Command::Command

    fn Command::Command(path : String) -> Command raise CommandError

    Reads a command path, such as kb validate or version. Words are separated by spaces. --help, -h, --version and -V are accepted.

    Command::description

    fn Command::description(self : Command) -> String

    One line that describes the command in the help text.

    Command::equal

    fn Command::equal(Command, Command) -> Bool
    automatically derived

    Command::not_equal

    fn Command::not_equal(x : Command, y : Command) -> Bool
    automatically derived

    Command::noun

    fn Command::noun(self : Command) -> Noun?

    The noun that the command belongs to. A single word, such as web, has none.

    Command::parse

    fn Command::parse(args : ArrayView[String]) -> (Command, ArrayView[String]) raise CommandError

    Reads the command at the start of the arguments, and returns it with the arguments that follow it. No arguments is the help command.

    Command::path

    fn Command::path(self : Command) -> Array[String]

    The words of the command on the command line, such as ["kb", "validate"].

    Command::path_text

    fn Command::path_text(self : Command) -> String

    The command path as one text, such as kb validate.

    Command::proton_id

    fn Command::proton_id(self : Command) -> String

    The ID of the Proton command that the desktop shell exposes: the path joined with . after mission-control..

    Command::to_repr

    automatically derived

    ConfigCommand

    pub(all) enum ConfigCommand {
    Show
    } derive(Eq,
    Debug
    )

    A verb of the config noun.

    ConfigCommand::equal

    automatically derived

    ConfigCommand::not_equal

    fn ConfigCommand::not_equal(x : ConfigCommand, y : ConfigCommand) -> Bool
    automatically derived

    ConfigCommand::to_repr

    automatically derived

    KbCommand

    pub(all) enum KbCommand {
    Validate
    Rules(RulesCommand)
    Profiles(ProfilesCommand)
    } derive(Eq,
    Debug
    )

    A verb of the kb noun, which checks and inspects knowledge bundles.

    KbCommand::equal

    fn KbCommand::equal(KbCommand, KbCommand) -> Bool
    automatically derived

    KbCommand::not_equal

    fn KbCommand::not_equal(x : KbCommand, y : KbCommand) -> Bool
    automatically derived

    KbCommand::to_repr

    automatically derived

    Noun

    pub(all) enum Noun {
    Kb
    KbRules
    KbProfiles
    Config
    Project
    } derive(Eq,
    Debug
    )

    A noun that groups commands. The help text lists each noun once.

    Noun::commands

    fn Noun::commands(self : Noun) -> Array[Command]

    The commands whose path starts with the path of the noun, in help order.

    Noun::description

    fn Noun::description(self : Noun) -> String

    One line that describes the noun in the help text.

    Noun::equal

    fn Noun::equal(Noun, Noun) -> Bool
    automatically derived

    Noun::not_equal

    fn Noun::not_equal(x : Noun, y : Noun) -> Bool
    automatically derived

    Noun::path

    fn Noun::path(self : Noun) -> Array[String]

    The words of the noun on the command line, such as ["kb", "rules"].

    Noun::path_text

    fn Noun::path_text(self : Noun) -> String

    The noun path as one text, such as kb rules.

    Noun::to_repr

    automatically derived

    ProfilesCommand

    pub(all) enum ProfilesCommand {
    List
    Show
    } derive(Eq,
    Debug
    )

    A verb of kb profiles.

    ProfilesCommand::equal

    automatically derived

    ProfilesCommand::not_equal

    fn ProfilesCommand::not_equal(x : ProfilesCommand, y : ProfilesCommand) -> Bool
    automatically derived

    ProfilesCommand::to_repr

    automatically derived

    ProjectCommand

    pub(all) enum ProjectCommand {
    Add
    Remove
    List
    Show
    } derive(Eq,
    Debug
    )

    A verb of the project noun, which changes and shows the project list of an instance.

    ProjectCommand::equal

    automatically derived

    ProjectCommand::not_equal

    fn ProjectCommand::not_equal(x : ProjectCommand, y : ProjectCommand) -> Bool
    automatically derived

    ProjectCommand::to_repr

    automatically derived

    RulesCommand

    pub(all) enum RulesCommand {
    List
    Show
    Check
    Test
    } derive(Eq,
    Debug
    )

    A verb of kb rules.

    RulesCommand::equal

    automatically derived

    RulesCommand::not_equal

    fn RulesCommand::not_equal(x : RulesCommand, y : RulesCommand) -> Bool
    automatically derived

    RulesCommand::to_repr

    automatically derived

    Version

    A version such as 0.0.2: three non-negative integer parts.
    impl Show for Version
    impl ToJson for Version

    Version::Version

    fn Version::Version(text : String) -> Version raise VersionError

    Parses X.Y.Z. Each part is a non-negative integer with at most nine digits and no leading zero.

    Version::compare

    fn Version::compare(Version, Version) -> Int
    automatically derived

    Version::current

    fn Version::current() -> Version

    The version of this module. It matches the workspace version.

    Version::equal

    fn Version::equal(Version, Version) -> Bool
    automatically derived

    Version::hash

    fn Version::hash(self : Version) -> Int
    automatically derived

    Version::hash_combine

    fn Version::hash_combine(Version, Hasher) -> Unit
    automatically derived

    Version::major

    fn Version::major(self : Version) -> Int

    Version::minor

    fn Version::minor(self : Version) -> Int

    Version::not_equal

    fn Version::not_equal(x : Version, y : Version) -> Bool
    automatically derived

    Version::op_ge

    fn Version::op_ge(x : Version, y : Version) -> Bool
    automatically derived

    Version::op_gt

    fn Version::op_gt(x : Version, y : Version) -> Bool
    automatically derived

    Version::op_le

    fn Version::op_le(x : Version, y : Version) -> Bool
    automatically derived

    Version::op_lt

    fn Version::op_lt(x : Version, y : Version) -> Bool
    automatically derived

    Version::output

    fn Version::output(self : Version, logger : &Logger) -> Unit

    Version::patch

    fn Version::patch(self : Version) -> Int

    Version::to_json

    The JSON form of a version is its text, such as "0.0.2".

    Version::to_repr

    automatically derived

    Version::to_string

    fn Version::to_string(self : Version) -> String

    commands

    let commands : ReadOnlyArray[Command]

    Every command, in the order that the help text lists them.

    nouns

    let nouns : ReadOnlyArray[Noun]

    The nouns at the top of the command tree, in help order.

    version

    fn version() -> Version

    The version of this module. It matches the workspace version.

    Source Files