Skip to content
This repository was archived by the owner on Aug 14, 2020. It is now read-only.

Commit f99814a

Browse files
committed
Merge pull request #17 from endocode/krnowak/cmake-rebase
goaci -> proj2aci, plus CMake builder
2 parents 1f5782c + b6a1351 commit f99814a

File tree

16 files changed

+1468
-548
lines changed

16 files changed

+1468
-548
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,7 @@ _testmain.go
2525

2626
bin/
2727
gopath/
28+
29+
*~
30+
*.aci
31+
/goaci

asset.go

Lines changed: 0 additions & 117 deletions
This file was deleted.

buildercommand.go

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
package main
2+
3+
import (
4+
"flag"
5+
"fmt"
6+
7+
"github.com/appc/goaci/proj2aci"
8+
)
9+
10+
// parameterMapper is an interface which should handle command line
11+
// parameter handling specific to a proj2aci.BuilderCustomizations
12+
// implementation.
13+
type parameterMapper interface {
14+
Name() string
15+
SetupParameters(parameters *flag.FlagSet)
16+
GetBuilderCustomizations() proj2aci.BuilderCustomizations
17+
}
18+
19+
// builderCommand is an implementation of command interface which
20+
// mainly maps command line parameters to proj2aci.Builder's
21+
// configuration and runs the builder.
22+
type builderCommand struct {
23+
mapper parameterMapper
24+
}
25+
26+
func newBuilderCommand(mapper parameterMapper) command {
27+
return &builderCommand{
28+
mapper: mapper,
29+
}
30+
}
31+
32+
func (cmd *builderCommand) Name() string {
33+
custom := cmd.mapper.GetBuilderCustomizations()
34+
return custom.Name()
35+
}
36+
37+
func (cmd *builderCommand) Run(name string, args []string) error {
38+
parameters := flag.NewFlagSet(name, flag.ExitOnError)
39+
cmd.mapper.SetupParameters(parameters)
40+
if err := parameters.Parse(args); err != nil {
41+
return err
42+
}
43+
if len(parameters.Args()) != 1 {
44+
return fmt.Errorf("Expected exactly one project to build, got %d", len(args))
45+
}
46+
custom := cmd.mapper.GetBuilderCustomizations()
47+
custom.GetCommonConfiguration().Project = parameters.Args()[0]
48+
builder := proj2aci.NewBuilder(custom)
49+
return builder.Run()
50+
}

command.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package main
2+
3+
// command provides an interface for named actions for command line
4+
// purposes.
5+
type command interface {
6+
// Name should return a name of a command usable at command
7+
// line.
8+
Name() string
9+
// Run should parse given args and perform some action. name
10+
// parameter is given for usage purposes.
11+
Run(name string, args []string) error
12+
}

commands.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package main
2+
3+
var (
4+
commandsMap map[string]command = make(map[string]command)
5+
)
6+
7+
func init() {
8+
commands := []command{
9+
newBuilderCommand(newGoParameterMapper()),
10+
newBuilderCommand(newCmakeParameterMapper()),
11+
}
12+
for _, c := range commands {
13+
commandsMap[c.Name()] = c
14+
}
15+
}

0 commit comments

Comments
 (0)