Skip to content
This repository has been archived by the owner on Feb 25, 2022. It is now read-only.

Commit

Permalink
Started on other description formats
Browse files Browse the repository at this point in the history
  • Loading branch information
pksunkara committed Jan 23, 2014
1 parent 382beb7 commit bc0ebb7
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 2 deletions.
25 changes: 24 additions & 1 deletion alpaca/alpaca.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package alpaca

import (
"bitbucket.org/pkg/inflect"
"fmt"
"os"
"path/filepath"
"strings"
)
Expand All @@ -12,6 +14,7 @@ const (

var (
LibraryRoot string
FormatList []string
)

type Data struct {
Expand All @@ -28,12 +31,32 @@ type LanguageOptions struct {
Node bool `long:"no-node" description:"Do not write node library"`
}

func WriteLibraries(directory string, opts *LanguageOptions) {
func LoadLibraryPath(directory string) {
var err error

LibraryRoot, err = filepath.Abs(directory)
HandleError(err)
}

func ConvertFormat(format string) {
acceptable := false

FormatList = []string{"blueprint"}

for _, v := range FormatList {
if v == format {
acceptable = true
}
}

if !acceptable {
fmt.Println("The given format is not allowed. Please choose one from the following:\n")
fmt.Println(strings.Join(FormatList, ", ") + "\n")
os.Exit(0)
}
}

func WriteLibraries(opts *LanguageOptions) {
data := ReadData()
ModifyData(data)

Expand Down
1 change: 1 addition & 0 deletions alpaca/format_blueprint.go
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package alpaca
10 changes: 9 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ func main() {
var opts struct {
Version bool `short:"v" long:"version" description:"Show version information"`

Format string `short:"f" long:"format" description:"API description format" value-name:"FORMAT"`

Langs alpaca.LanguageOptions `group:"Language Options"`
}

Expand Down Expand Up @@ -41,5 +43,11 @@ func main() {
os.Exit(0)
}

alpaca.WriteLibraries(args[0], &opts.Langs)
alpaca.LoadLibraryPath(args[0])

if opts.Format != "" {
alpaca.ConvertFormat(opts.Format)
}

alpaca.WriteLibraries(&opts.Langs)
}

0 comments on commit bc0ebb7

Please sign in to comment.