Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(16)

Side by Side Diff: mojom/mojom_parser/mojom_main.go

Issue 1833493002: Replace ErrorExit with log.Fatal in the mojom tool. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « mojom/mojom_parser/fmt_cmd.go ('k') | mojom/mojom_parser/parse_cmd.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package main 5 package main
6 6
7 import ( 7 import (
8 "bytes" 8 "bytes"
9 "flag" 9 "flag"
10 "fmt" 10 "fmt"
11 "log"
11 "os" 12 "os"
12 ) 13 )
13 14
14 // This file contains the main() for the mojom tool binary. 15 // This file contains the main() for the mojom tool binary.
15 // The mojom tool is used to process .mojom files. 16 // The mojom tool is used to process .mojom files.
16 // 17 //
17 // The tool is invoked as follows: 18 // The tool is invoked as follows:
18 // 19 //
19 // mojom <command> [<arguments>] 20 // mojom <command> [<arguments>]
20 // 21 //
21 // where <commands> is one of: 22 // where <commands> is one of:
22 // - parse 23 // - parse
23 // - fmt 24 // - fmt
24 // 25 //
25 // For further information about each command, see the file named 26 // For further information about each command, see the file named
26 // <command>_cmd.go for example "parse_cmd.go" and "fmt_cmd.go". 27 // <command>_cmd.go for example "parse_cmd.go" and "fmt_cmd.go".
27 func main() { 28 func main() {
29 log.SetFlags(0)
28 checkVersion(os.Args) 30 checkVersion(os.Args)
29 commands := NewCommandSet() 31 commands := NewCommandSet()
30 commands.AddCommand("parse", parseCmd, "Parses mojom files.") 32 commands.AddCommand("parse", parseCmd, "Parses mojom files.")
31 commands.AddCommand("fmt", fmtCmd, "Formats a mojom file.") 33 commands.AddCommand("fmt", fmtCmd, "Formats a mojom file.")
32 commands.AddHelpCommand() 34 commands.AddHelpCommand()
33 commands.RunCommand(os.Args) 35 commands.RunCommand(os.Args)
34 } 36 }
35 37
36 func ErrorExit(message string) {
37 fmt.Fprintf(os.Stderr, "%s\n", message)
38 os.Exit(1)
39 }
40
41 type command struct { 38 type command struct {
42 Name string 39 Name string
43 Func func([]string) 40 Func func([]string)
44 Desc string 41 Desc string
45 } 42 }
46 43
47 type commandSet struct { 44 type commandSet struct {
48 commandNames []string 45 commandNames []string
49 commandMap map[string]command 46 commandMap map[string]command
50 } 47 }
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 s += "\n \t" 125 s += "\n \t"
129 s += f.Usage 126 s += f.Usage
130 if !isZeroValue(f.DefValue) { 127 if !isZeroValue(f.DefValue) {
131 s += fmt.Sprintf(" (default %q)", f.DefValue) 128 s += fmt.Sprintf(" (default %q)", f.DefValue)
132 } 129 }
133 b.WriteString(fmt.Sprint(s, "\n")) 130 b.WriteString(fmt.Sprint(s, "\n"))
134 }) 131 })
135 132
136 return b.String() 133 return b.String()
137 } 134 }
OLDNEW
« no previous file with comments | « mojom/mojom_parser/fmt_cmd.go ('k') | mojom/mojom_parser/parse_cmd.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698