def common_errs

cswap-bend-cli@0.1.0.0 · args.bend:174

import cswap-bend-cli@0.1.0.0/args.bend as Args
import Base

174def common_errs(+vb: String, +os: List<&2, Opt>) -> List<&2, String>:
175  [err_if(opt.has("--token-status", os) && Bool.not(String.eq(vb, "list")), "--token-status can only be used with 'list'"),
176   err_if(opt.has("--json", os) && Bool.not(has_str(vb, ["list", "status", "switch"])), "--json can only be used with 'list', 'status', or 'switch'"),
177   err_if(opt.has("--json", os) && opt.has("--token-status", os), "--token-status cannot be combined with --json"),
178   err_if(opt.has("--strategy", os) && Bool.not(String.eq(vb, "switch")), "--strategy can only be used with bare 'switch'"),
179   err_if(opt.has("--model", os) && Bool.not(opt.has("--strategy", os)), "--model can only be used with 'switch --strategy best' or 'switch --strategy next-available'"),
180   err_if(opt.has("--slot", os) && Bool.not(has_str(vb, ["add", "add-token"])), "--slot can only be used with 'add' or 'add-token'"),
181   err_if(opt.has("--email", os) && Bool.not(String.eq(vb, "add-token")), "--email can only be used with 'add-token'"),
182   err_if(opt.has("--account", os) && Bool.not(String.eq(vb, "export")), "--account can only be used with 'export'"),
183   err_if(opt.has("--alias", os) && Bool.not(String.eq(vb, "add")), "--alias can only be used with 'add'"),
184   err_if(opt.has("--force", os) && Bool.not(has_str(vb, ["import", "switch"])), "--force can only be used with 'import' or 'switch <num|email>'"),
185   err_if(opt.has("--full", os) && Bool.not(String.eq(vb, "export")), "--full can only be used with 'export'"),
186   err_if(opt.has("--hold", os) && Bool.not(String.eq(vb, "import-usage")), "--hold can only be used with 'import-usage'"),
187   err_if(opt.has("--strategy", os) && String.eq(vb, "switch") && Bool.not(List.is_empty(&2, String, positionals(os))), "--strategy can only be used with bare 'switch'"),
188   err_if(opt.has("--force", os) && String.eq(vb, "switch") && List.is_empty(&2, String, positionals(os)), "--force can only be used with 'import' or 'switch <num|email>'"),
189   strategy_err(opt.val("--strategy", os)),
190   err_if((opt.has("--install-service", os) || opt.has("--uninstall-service", os) || opt.has("--service-status", os)) && Bool.not(String.eq(vb, "menubar")),
191     "--install-service, --uninstall-service and --service-status can only be used with 'menubar'")]

Uses (14)

Used by (1)