-
Notifications
You must be signed in to change notification settings - Fork 154
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from ipinfo/uman/pre-v1-fixes
Pre-v1 fixes/updates
- Loading branch information
Showing
23 changed files
with
626 additions
and
419 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
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,41 @@ | ||
#!/bin/bash | ||
|
||
# Build binary for all platforms for version $1. | ||
|
||
set -e | ||
|
||
DIR=`dirname $0` | ||
ROOT=$DIR/.. | ||
|
||
VSN=$1 | ||
|
||
if [ -z "$VSN" ]; then | ||
echo "require version as first parameter" 2>&1 | ||
exit 1 | ||
fi | ||
|
||
for t in \ | ||
darwin_amd64 \ | ||
dragonfly_amd64 \ | ||
freebsd_amd64 \ | ||
linux_amd64 \ | ||
netbsd_amd64 \ | ||
openbsd_amd64 \ | ||
plan9_amd64 \ | ||
solaris_amd64 \ | ||
windows_amd64 ; | ||
do | ||
os="${t%_*}" | ||
arch="${t#*_}" | ||
output="grepip_${VSN}_${os}_${arch}" | ||
|
||
if [ "$os" == "windows" ] ; then | ||
output+=".exe" | ||
fi | ||
|
||
GOOS=$os GOARCH=$arch go build \ | ||
-o $ROOT/build/${output} \ | ||
$ROOT/grepip & | ||
done | ||
|
||
wait |
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. | ||
|
||
DIR=`dirname $0` | ||
ROOT=$DIR/.. | ||
|
||
go build \ | ||
-o $ROOT/build/grepip \ | ||
$ROOT/grepip |
File renamed without changes.
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: grepip | ||
Section: utils | ||
Version: 1.0.0 | ||
Priority: optional | ||
Maintainer: IPinfo <[email protected]> | ||
Vcs-Git: https://github.com/ipinfo/cli | ||
Vcs-browser: https://github.com/ipinfo/cli | ||
Homepage: https://ipinfo.io | ||
Package: grepip | ||
Architecture: amd64 | ||
Description: A grep-like tool for filtering IPv4 and IPv6 addresses. |
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,63 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"path/filepath" | ||
|
||
"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: grepip [<opts>] | ||
Options: | ||
General: | ||
--only-matching, -o | ||
print only matched IP in result line, excluding surrounding content. | ||
--no-filename, -h | ||
don't print source of match in result lines when more than 1 source. | ||
--no-recurse | ||
don't recurse into more directories in directory sources. | ||
--version | ||
show binary release number. | ||
--help | ||
show help. | ||
Filters: | ||
--ipv4, -4 | ||
match only IPv4 addresses. | ||
--ipv6, -6 | ||
match only IPv6 addresses. | ||
--exclude-reserved, -x | ||
exclude reserved/bogon IPs. | ||
full list can be found at https://ipinfo.io/bogon. | ||
`) | ||
} | ||
|
||
func cmd() error { | ||
var fVsn bool | ||
|
||
f := lib.CmdGrepIPFlags{} | ||
f.Init() | ||
pflag.BoolVarP(&fVsn, "version", "", false, "print binary release number.") | ||
pflag.Parse() | ||
|
||
if fVsn { | ||
fmt.Println(version) | ||
return nil | ||
} | ||
|
||
return lib.CmdGrepIP(f, pflag.Args(), printHelp) | ||
} | ||
|
||
func main() { | ||
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,44 @@ | ||
#!/bin/bash | ||
|
||
# Build and upload (to GitHub) for all platforms for version $1. | ||
|
||
set -e | ||
|
||
DIR=`dirname $0` | ||
ROOT=$DIR/.. | ||
|
||
VSN=$1 | ||
|
||
if [ -z "$VSN" ]; then | ||
echo "require version as first parameter" 2>&1 | ||
exit 1 | ||
fi | ||
|
||
# build | ||
rm -f $ROOT/build/grepip_${VSN}* | ||
$ROOT/grepip/build-all-platforms.sh "$VSN" | ||
|
||
# archive | ||
cd $ROOT/build | ||
for t in grepip_${VSN}_* ; do | ||
if [[ $t == grepip_*_windows_* ]]; then | ||
zip -q ${t/.exe/.zip} $t | ||
else | ||
tar -czf ${t}.tar.gz $t | ||
fi | ||
done | ||
cd .. | ||
|
||
# dist: debian | ||
rm -rf $ROOT/grepip/dist/usr | ||
mkdir -p $ROOT/grepip/dist/usr/local/bin | ||
cp $ROOT/build/grepip_${VSN}_linux_amd64 $ROOT/grepip/dist/usr/local/bin/grepip | ||
dpkg-deb --build ${ROOT}/grepip/dist build/grepip_${VSN}.deb | ||
|
||
# release | ||
gh release create grepip-${VSN} \ | ||
-R ipinfo/cli \ | ||
-t "grepip-${VSN}" \ | ||
$ROOT/build/grepip_*.tar.gz \ | ||
$ROOT/build/grepip_*.zip \ | ||
$ROOT/build/grepip_*.deb |
File renamed without changes.
File renamed without changes.
Oops, something went wrong.