Skip to content

Commit

Permalink
Merge pull request #9 from daedaleanai/jf-v0.1.4
Browse files Browse the repository at this point in the history
Completions
  • Loading branch information
jfrohnhofen authored Feb 11, 2021
2 parents b8946d2 + dec221b commit 88e49f6
Show file tree
Hide file tree
Showing 12 changed files with 1,235 additions and 124 deletions.
22 changes: 12 additions & 10 deletions RULES/core/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,8 @@ var allowNewFlags = true
var BuildFlags = map[string]string{}

func flagValue(name string) string {
prefix := fmt.Sprintf("--%s=", name)
trueFlag := fmt.Sprintf("--%s", name)
prefix := fmt.Sprintf("%s=", name)
for _, arg := range os.Args[4:] {
if arg == trueFlag {
return "true"
}
if strings.HasPrefix(arg, prefix) {
return strings.TrimPrefix(arg, prefix)
}
Expand Down Expand Up @@ -71,20 +67,26 @@ func Fatal(format string, a ...interface{}) {
return
}
msg := fmt.Sprintf(format, a...)
fmt.Fprintf(os.Stderr, "A fatal error occured while processing target '%s': %s", currentTarget, msg)
if currentTarget == "" {
fmt.Fprintf(os.Stderr, "A fatal error occured: %s", msg)
} else {
fmt.Fprintf(os.Stderr, "A fatal error occured while processing target '%s': %s", currentTarget, msg)
}
os.Exit(1)
}

// Assert can be used in build rules to abort build file generation with an error message if `cond` is true.
func Assert(cond bool, format string, a ...interface{}) {
// Ignore all asserts when not generating the ninja build file. This allows listing all targets in a workspace
// without specifying required build flags.
if mode() != "ninja" {
if cond || mode() != "ninja" {
return
}
if !cond {
msg := fmt.Sprintf(format, a...)
msg := fmt.Sprintf(format, a...)
if currentTarget == "" {
fmt.Fprintf(os.Stderr, "Assertion failed: %s", msg)
} else {
fmt.Fprintf(os.Stderr, "Assertion failed while processing target '%s': %s", currentTarget, msg)
os.Exit(1)
}
os.Exit(1)
}
2 changes: 1 addition & 1 deletion cmd/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
)

var addCmd = &cobra.Command{
Use: "add <repository> <version>",
Use: "add [repository] [version]",
Args: cobra.ExactArgs(2),
Short: "Adds a dependency to the MODULE file of the current module",
Long: `Adds a dependency to the MODULE file of the current module.
Expand Down
Loading

0 comments on commit 88e49f6

Please sign in to comment.