GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - semk/argparse: Simple and elegant command line argument parser for shell scripts.

BranchesTags
Open more actions menu

Latest commit

 

History

19 Commits
19 Commits

Folders and files

NameName
Last commit message
Last commit date
.github/workflows
.github/workflows
 
 
.gitignore
.gitignore
 
 
.travis.yml
.travis.yml
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
argparse.go
argparse.go
 
 

Repository files navigation

argparse

Simple and elegant command line argument parser for scripts that can be used as a shebang (Bash | Python | Perl etc.)

Installation

go get github.com/semk/argparse
cp $(go env GOPATH)/bin/argparse /usr/local/bin

Usage

Usage of ./argparse:
  -arg value
    	Define custom argument to the program. Format: name::default:desc
  -executor string
    	Path to the script executor (set this to shebang (#!)) (default "/bin/bash")

And the last arguments can be the script with the arguments to be called.

in scripts #!

#!/usr/local/bin/argparse --executor=/bin/bash --arg=name::NoNameDefined::Name

direct usage

argparse --executor=/bin/bash --arg=name::NoNameDefined::Name printname.sh --name Sreejith

The defined args would then be available as capitalized envirionment variables with the ARG_<OPTION_NAME> format.

Example

This example shows how argparse can be used as a #! in a bash script for commandline parsing. The following file is named printname.sh.

#!/usr/local/bin/argparse --executor=/bin/bash --arg=name::NoNameDefined::Name

echo "This program prints names passed to the argument --name."
echo "Name: ${ARG_NAME}"
$ ./printname.sh --name Sreejith
This program prints names passed to the argument --name.
Name: Sreejith
$ ./printname.sh                
This program prints names passed to the argument --name.
Name: NoNameDefined
$ ./printname.sh --help
Usage of ./printname.sh:
  -name string
    	Name (default "NoNameDefined")

About

Simple and elegant command line argument parser for shell scripts.

Topics

argparseargument-parserbashgolang

Resources

Readme
MIT license
Activity

Stars

3 stars

Watchers

1 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.