Skip to content

Commit

Permalink
rename opts to getopt, add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
lukesampson committed Sep 6, 2013
1 parent b494bfb commit 9724040
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 4 deletions.
8 changes: 8 additions & 0 deletions lib/opts.ps1 → lib/getopt.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
# adapted from http://hg.python.org/cpython/file/2.7/Lib/getopt.py
# argv:
# array of arguments
# shortopts:
# string of single-letter options. options that take a parameter
# should be follow by ':'
# longopts:
# array of strings that are long-form options. options that take
# a parameter should end with '='
# returns @(opts hash, rem_args array, error string)
function getopt($argv, $shortopts, $longopts) {
$opts = @{}; $rem = @()
Expand Down
2 changes: 1 addition & 1 deletion libexec/scoop-install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
. "$psscriptroot\..\lib\install.ps1"
. "$psscriptroot\..\lib\versions.ps1"
. "$psscriptroot\..\lib\help.ps1"
. "$psscriptroot\..\lib\opts.ps1"
. "$psscriptroot\..\lib\getopt.ps1"

function install($app, $architecture, $global) {
$app, $manifest, $bucket, $url = locate $app
Expand Down
2 changes: 1 addition & 1 deletion libexec/scoop-uninstall.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
. "$psscriptroot\..\lib\help.ps1"
. "$psscriptroot\..\lib\install.ps1"
. "$psscriptroot\..\lib\versions.ps1"
. "$psscriptroot\..\lib\opts.ps1"
. "$psscriptroot\..\lib\getopt.ps1"

# options
$opt, $app, $err = getopt $args 'g' 'global'
Expand Down
2 changes: 1 addition & 1 deletion libexec/scoop-update.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
. "$psscriptroot\..\lib\manifest.ps1"
. "$psscriptroot\..\lib\buckets.ps1"
. "$psscriptroot\..\lib\versions.ps1"
. "$psscriptroot\..\lib\opts.ps1"
. "$psscriptroot\..\lib\getopt.ps1"

$opt, $app, $err = getopt $args 'g' 'global'
if($err) { "scoop update: $err"; exit 1 }
Expand Down
2 changes: 1 addition & 1 deletion test/opts.ps1
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
. "$psscriptroot\tests.ps1"
. "$psscriptroot\..\lib\opts.ps1"
. "$psscriptroot\..\lib\getopt.ps1"

filter_tests $args

Expand Down

0 comments on commit 9724040

Please sign in to comment.