From ebfe2e5796072629a300d2dec15d434f5a5e0460 Mon Sep 17 00:00:00 2001 From: Karan Misra Date: Mon, 7 Apr 2014 02:37:49 +0530 Subject: [PATCH] cli: initial commit this introduces the embd cli tool --- README.md | 20 ++++++++++++++++++-- embd/.gitignore | 1 + embd/detect.go | 28 ++++++++++++++++++++++++++++ embd/main.go | 26 ++++++++++++++++++++++++++ 4 files changed, 73 insertions(+), 2 deletions(-) create mode 100644 embd/.gitignore create mode 100644 embd/detect.go create mode 100644 embd/main.go diff --git a/README.md b/README.md index cbab14f..2c1e1e7 100644 --- a/README.md +++ b/README.md @@ -13,9 +13,25 @@ Development sponsored by [**ThoughtWorks**](http://www.thoughtworks.com/) * [Cubietruck](http://www.cubietruck.com/) **coming soon** * Bring Your Own **coming soon** -## How to use +## The command line tool -Package embd provides a superheroic hardware abstraction layer for doing embedded programming + go get github.com/kidoman/embd/embd + +will install a command line utility ```embd``` which will allow you to quickly get started with prototyping. The binary should be available in your ```$GOPATH/bin```. However, to be able to run this on a ARM based device, you will need to build it with ```GOOS=linux``` and ```GOARCH=arm``` environment variables set. + +But, since I am feeling so generous, a prebuilt/tested version is available for direct download and deployment [here](https://dl.dropboxusercontent.com/u/6727135/Binaries/embd/linux-arm/embd). + +For example, if you run ```embd detect``` on a **BeagleBone Black**: + + root@beaglebone:~# embd detect + + detected host BeagleBone Black (rev 0) + +Run ```embd``` without any arguments to discover the various commands supported by the utility. + +## How to use the framework + +Package **embd** provides a hardware abstraction layer for doing embedded programming on supported platforms like the Raspberry Pi and BeagleBone Black. Most of the examples below will work without change (i.e. the same binary) on all supported platforms. How cool is that? diff --git a/embd/.gitignore b/embd/.gitignore new file mode 100644 index 0000000..4b8fe53 --- /dev/null +++ b/embd/.gitignore @@ -0,0 +1 @@ +embd \ No newline at end of file diff --git a/embd/detect.go b/embd/detect.go new file mode 100644 index 0000000..8d268e6 --- /dev/null +++ b/embd/detect.go @@ -0,0 +1,28 @@ +package main + +import ( + "fmt" + "os" + + "github.com/codegangsta/cli" + "github.com/kidoman/embd" +) + +func detect(c *cli.Context) { + host, rev, err := embd.DetectHost() + if err != nil { + fmt.Println(err) + os.Exit(1) + } + fmt.Printf("detected host %v (rev %v)\n", host, rev) +} + +var detectCmd = cli.Command{ + Name: "detect", + Usage: "detect and display information about the host", + Action: detect, +} + +func init() { + registerCommand(detectCmd) +} diff --git a/embd/main.go b/embd/main.go new file mode 100644 index 0000000..5326ec4 --- /dev/null +++ b/embd/main.go @@ -0,0 +1,26 @@ +package main + +import ( + "os" + + "github.com/codegangsta/cli" + _ "github.com/kidoman/embd/host/all" +) + +var version = "0.1.0" + +var commands []cli.Command + +func registerCommand(cmd cli.Command) { + commands = append(commands, cmd) +} + +func main() { + app := cli.NewApp() + app.Name = "embd" + app.Usage = "superheroic embedded utility belt" + app.Version = version + app.Commands = commands + + app.Run(os.Args) +}