moonbitstack/moonctl/style does not have a README file

    Refused

    pub(all) suberror Refused {
    BadStyle(String)
    }

    A --style template that is not <before>GO<through>ZERO<after>: either a marker is missing (go, zero), they are the wrong way round, or one is cased neither go/GO/Go nor zero/ZERO/Zero (gOZero, goZEro).

    Case

    type Case

    The case a marker asks its words to be spelled in.

    Naming

    pub(all) enum Naming {
    Snake
    Camel
    Pascal
    Kebab
    ScreamingSnake
    }

    The casing a generated name takes.

    Naming::spell

    fn Naming::spell(self : Naming, name : String) -> String

    name in this casing.

    NamingPolicy

    pub(all) struct NamingPolicy {
    table : Naming
    column : Naming
    plural : Bool
    }

    How a spec's own names are spelled in SQL: the table a type block becomes, its columns, and whether a table is named for one row (user) or for the set (users).

    NamingPolicy::column_name

    fn NamingPolicy::column_name(self : NamingPolicy, name : String) -> String

    The column a field called name becomes, under this policy.

    NamingPolicy::of_info

    fn NamingPolicy::of_info(info : Array[(String, String)]) -> NamingPolicy?

    The policy a spec's info block asks for, or None when it asks for none — which leaves each generator spelling names the way it always has. A value that is not a casing is left at the default and named by naming_problems, which validate reports, so generation never guesses a spelling the spec did not ask for.

    NamingPolicy::table_name

    fn NamingPolicy::table_name(self : NamingPolicy, name : String) -> String

    The table a type block called name becomes, under this policy.

    Style

    pub struct Style {
    before : String
    through : String
    after : String
    head : Case
    tail : Case
    }

    A --style naming template (← goctl's --style), ready to spell names with. Build one with Style::parse, apply it with Style::format.

    Style::format

    fn Style::format(self : Style, name : String) -> String

    Spell name in this style. name is split into words on _ and before each capital, the first word takes the GO marker's case and the rest take ZERO's, and they are joined with whatever stood between the markers.

    Style::gozero

    fn Style::gozero() -> Style

    goctl's default style, gozero: every word lower-cased and run together.

    Style::parse

    fn Style::parse(s : String) -> Style raise Refused

    Read a --style template. It must contain GO and then ZERO — in any case, with anything before, between and after them:

    Style::parse("gozero").format("welcome_to_go_zero") // welcometogozero Style::parse("goZero").format("welcome_to_go_zero") // welcomeToGoZero Style::parse("go_zero").format("welcome_to_go_zero") // welcome_to_go_zero Style::parse("Go#zero").format("welcome_to_go_zero") // Welcome#to#go#zero

    The GO marker's own casing (go, GO or Go) says how the first word is spelled, ZERO's says how every later word is, and what stands between the two markers is what stands between the words. A template missing a marker (go, zero), holding them in the wrong order, or casing one of them any other way (gOZero, goZEro) raises Refused.

    default_naming

    let default_naming : NamingPolicy

    The policy a spec that says nothing gets: lower snake for both, one row per name — the spelling every SQL style guide starts from.

    naming_problems

    fn naming_problems(info : Array[(String, String)]) -> Array[String]

    What the spec's info block says that NamingPolicy could not read, one line per entry, for validate to report: a naming key with a value that is not a casing, or with no value at all.