Skip to content

Implement Variants and pattern matching to make it easy to add new commands. #2

@ProCode2

Description

@ProCode2

Right now because there is no defined set of commands, I didn't do this right away.

Create variants

type command =
  | CreateDir(option<string>)
  | CreateCurrentDir
  | Help
  | Something;

Then while parsing the command

// in command parser
switch command {
  | "help" => Help
  |  "recognisable" => Something
  }

// actual actions
switch cmnd {
| Help => printHelp()
| CreateDir(dir) => // create a directory
| Something => // do something
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions