amber-lang / amber-lang/amber

[Feature] Implement command line parser builtin

Aberta
#613 9 comentários 2 reações 1 responsável Reivindicada por @hdwalters Ver no GitHub
enhancement
Linguagem predominante
Rust
Estrelas
5.2k
Forks
145
Merge médio
5d 3h
PRs com merge (30d)
7

Descrição

**Is your feature request related to a problem? Please describe.**
When writing Bash scripts taking command line options, I use `getopt` to preprocess the command line, and a `while` loop and `case` statement to handle individual options:

```
#!/usr/bin/env bash

# Parse command line or print help text.
script=""
files=()
title=""
items=()
depth=0
ultra=0
verbose=0
getopt=$(getopt --options=t:i:d:uv --longoptions=title:,items:,depth:,ultra,verbose,help -- "$@") || exit
eval set -- $getopt
while true; do
case "$1" in
-t|--title)
title="$2"
shift
shift
;;
-i|--items)
items+=("$2")
shift
shift
;;
-d|--depth)
depth="$2"
shift
shift
;;
-u|--ultra)
ultra=1
shift
;;
-v|--verbose)
verbose=1
shift
;;
--help)
cat <

Guia de contribuição

Nenhum guia de contribuição indexado para este repositório

Avaliação

Esta issue ainda não foi avaliada.

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.