Dude, Where's My
dudewheresmy
is a portable tool for obtaining environment- or context-specific information at runtime.
Installation
You need Go to build this tool.
$ go get github.com/asicsdigital/dudewheresmy
You should now have an executable at $GOPATH/bin/dudewheresmy
.
Usage
$ dudewheresmy
NAME:
dudewheresmy - find things you're looking for
USAGE:
dudewheresmy [global options] command [command options] [arguments...]
VERSION:
v0.1.0
COMMANDS:
hostip, i, ip, host find IP address of process host
help, h Shows a list of commands or help for one command
GLOBAL OPTIONS:
--help, -h show help
--version, -v print the version
hostip
From userspace on a POSIX system, hostip
returns localhost:
$ dudewheresmy hostip
127.0.0.1
From inside a Docker container, hostip
returns a lookup of host.docker.internal.
:
$ docker run --rm -it asicsdigital/dudewheresmy:latest hostip
192.168.65.2
From an EC2 instance, hostip
returns a lookup of local-ipv4
from the metadata service:
$ dudewheresmy hostip
10.1.20.222
Contributing
This tool is built with urfave/cli. To add another subcommand:
mkdir -p commands/<YOUR SUBCOMMAND>
$EDITOR commands/<YOUR SUBCOMMAND>/<YOUR SUBCOMMAND>.go
- Declare a new package namespace for your subcommand.
- Define a
Command()
function that returns a cli.Command
struct
- Import
github.com/asicsdigital/dudewheresmy/commands/<YOUR SUBCOMMAND>
from main.go