cli-utils-4.1.0
LicenseBSD3
Maintainertbidne@gmail.com
Safe HaskellSafe
LanguageHaskell2010

CLI.Internal

Description

Provides a function that parses command keys into their values.

Synopsis

Documentation

translateCommands :: Map Text Text -> [Text] -> [Text] Source #

Returns a list of Text commands, potentially transforming a given string via the Map legend.

For a string \(s = s_1,\ldots,s_n\), we split \(s\) by commas then recursively search on each \(s_i\). We stop and return \(s_i\) when it does not exist as a key in the map.

For example,

  m = { "cmd1": "one", "cmd2": "two", "all": "cmd1,cmd2,other" }
  translateCommands m ["all", "blah"] == ["one", "two", "other", "blah"]