Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100755 75 lines (53 sloc) 0.926 kb
73896ff TJ Holowaychuk Initial commit
authored
1 #!/usr/bin/env sh
2
1667a31 TJ Holowaychuk Started n(1)
authored
3 # Library version
4
5 VERSION="0.0.1"
6
7 # curl / wget support
8
9 GET=
10
11 # wget support
12 which wget > /dev/null && GET="wget -q -O-"
13
14 # curl support
15 which curl > /dev/null && GET="curl -# -L"
16
d3ac35d TJ Holowaychuk abort
authored
17 # Ensure we have curl or wget
18
19 test -z "$GET" && abort "curl or wget required"
20
1667a31 TJ Holowaychuk Started n(1)
authored
21 #
22 # Log the given <msg ...>
23 #
24
25 log() {
26 echo "... $@"
27 }
28
29 #
d3ac35d TJ Holowaychuk abort
authored
30 # Exit with the given <msg ...>
31 #
32
33 abort() {
34 echo "Error: $@" && exit 1
35 }
36
37 #
1667a31 TJ Holowaychuk Started n(1)
authored
38 # Output usage information.
39 #
40
41 display_help() {
42 cat <<-help
43
44 Usage: n [options] <version>
45
46 Options:
47
48 -V, --version Output current version of n
49 -h, --help Display help information
50
51 help
52 exit 0
53 }
54
55 #
56 # Output n version.
57 #
58
59 display_n_version() {
60 echo $VERSION && exit 0
61 }
62
63 # Handle arguments
64
65 if test $# -eq 0; then
66 display_versions
67 else
68 while test $# -ne 0; do
69 case $1 in
70 -V|--version) display_n_version ;;
71 -h|--help) display_help ;;
72 esac
73 shift
74 done
75 fi
Something went wrong with that request. Please try again.