forked from ipinfo/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add boilerplate in prep for impl and refactor build scripts.
- Loading branch information
1 parent
63839c5
commit f6bc145
Showing
33 changed files
with
492 additions
and
172 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
.vim/ | ||
ipinfo/dist/ | ||
grepip/dist/ | ||
cidr2range/dist/ | ||
range2cidr/dist/ | ||
!ipinfo/dist/DEBIAN/ | ||
!grepip/dist/DEBIAN/ | ||
!cidr2range/dist/DEBIAN/ | ||
!range2cidr/dist/DEBIAN/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/bash | ||
|
||
# Build binary for all platforms for version $1. | ||
|
||
set -e | ||
|
||
DIR=`dirname $0` | ||
ROOT=$DIR/.. | ||
|
||
VSN=$1 | ||
|
||
$ROOT/scripts/build-all-platforms.sh "cidr2range" $VSN |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/bin/bash | ||
|
||
# Build local binary. | ||
|
||
set -e | ||
|
||
DIR=`dirname $0` | ||
ROOT=$DIR/.. | ||
|
||
$ROOT/scripts/build.sh "cidr2range" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package main | ||
|
||
import ( | ||
"github.com/ipinfo/cli/lib" | ||
"github.com/ipinfo/cli/lib/complete" | ||
) | ||
|
||
var completions = lib.CompletionsCIDR2Range | ||
|
||
func handleCompletions() { | ||
completions.Complete(progBase) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/bin/sh | ||
|
||
VSN=1.0.0 | ||
|
||
curl -LO https://github.com/ipinfo/cli/releases/download/cidr2range-${VSN}/cidr2range_${VSN}.deb | ||
sudo dpkg -i cidr2range_${VSN}.deb | ||
rm cidr2range_${VSN}.deb | ||
|
||
echo | ||
echo 'You can now run `cidr2range`'. | ||
|
||
if [ -f "$0" ]; then | ||
rm $0 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
Source: cidr2range | ||
Section: utils | ||
Version: 1.0.0 | ||
Priority: optional | ||
Maintainer: IPinfo <support@ipinfo.io> | ||
Vcs-Git: https://github.com/ipinfo/cli | ||
Vcs-browser: https://github.com/ipinfo/cli | ||
Homepage: https://ipinfo.io | ||
Package: cidr2range | ||
Architecture: amd64 | ||
Description: A simple tool for converting from CIDRs to IP ranges. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/bin/sh | ||
|
||
VSN=1.0.0 | ||
PLAT=darwin_amd64 | ||
|
||
curl -LO https://github.com/ipinfo/cli/releases/download/cidr2range-${VSN}/cidr2range_${VSN}_${PLAT}.tar.gz | ||
tar -xf cidr2range_${VSN}_${PLAT}.tar.gz | ||
rm cidr2range_${VSN}_${PLAT}.tar.gz | ||
mv cidr2range_${VSN}_${PLAT} /usr/local/bin/cidr2range | ||
|
||
echo | ||
echo 'You can now run `cidr2range`'. | ||
|
||
if [ -f "$0" ]; then | ||
rm $0 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"path/filepath" | ||
|
||
"github.com/fatih/color" | ||
"github.com/ipinfo/cli/lib" | ||
"github.com/spf13/pflag" | ||
) | ||
|
||
var progBase = filepath.Base(os.Args[0]) | ||
var version = "1.0.0" | ||
|
||
func printHelp() { | ||
fmt.Printf( | ||
`Usage: %s [<opts>] | ||
Options: | ||
--version, -v | ||
show binary release number. | ||
--help, -h | ||
show help. | ||
`, progBase) | ||
} | ||
|
||
func cmd() error { | ||
var fVsn bool | ||
|
||
f := lib.CmdCIDR2RangeFlags{} | ||
f.Init() | ||
pflag.BoolVarP(&fVsn, "version", "v", false, "print binary release number.") | ||
pflag.Parse() | ||
|
||
if fVsn { | ||
fmt.Println(version) | ||
return nil | ||
} | ||
|
||
return lib.CmdCIDR2Range(f, pflag.Args(), printHelp) | ||
} | ||
|
||
func main() { | ||
// obey NO_COLOR env var. | ||
if os.Getenv("NO_COLOR") != "" { | ||
color.NoColor = true | ||
} | ||
|
||
handleCompletions() | ||
|
||
if err := cmd(); err != nil { | ||
fmt.Printf("err: %v\n", err) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/bash | ||
|
||
# Build and upload (to GitHub) for all platforms for version $1. | ||
|
||
set -e | ||
|
||
DIR=`dirname $0` | ||
ROOT=$DIR/.. | ||
|
||
VSN=$1 | ||
|
||
$ROOT/scripts/release.sh "cidr2range" $VSN |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,4 +9,6 @@ rm grepip_${VSN}.deb | |
echo | ||
echo 'You can now run `grepip`'. | ||
|
||
rm $0 | ||
if [ -f "$0" ]; then | ||
rm $0 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/ipinfo/cli/lib" | ||
"github.com/spf13/pflag" | ||
) | ||
|
||
func printHelpCIDR2Range() { | ||
fmt.Printf( | ||
`Usage: %s cidr2range [<opts>] | ||
Options: | ||
--help, -h | ||
show help. | ||
`, progBase) | ||
} | ||
|
||
func cmdCIDR2Range() (err error) { | ||
f := lib.CmdCIDR2RangeFlags{} | ||
f.Init() | ||
pflag.Parse() | ||
|
||
return lib.CmdCIDR2Range(f, pflag.Args()[1:], printHelpCIDR2Range) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.