-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli.go
More file actions
45 lines (35 loc) · 830 Bytes
/
cli.go
File metadata and controls
45 lines (35 loc) · 830 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package main
import (
"fmt"
"github.com/alexflint/go-arg"
)
var (
version = "dev"
commit = "none"
date = "unknown"
)
type argsParsed struct {
args
}
type args struct {
// File config
FileName string `arg:"required" help:"File to assemble"`
// Logging config
Logging bool `arg:"-l,--logging" help:"Enable logging"`
}
// Returns a human-readable version string
func (args) Version() string {
return fmt.Sprintf("Version: %v, commit: %v, built at: %v", version, commit, date)
}
// Returns a description of the program
func (args) Description() string {
return "A simple assembler for the RISC-V (RV32I) architecture"
}
// Returns the parsed CLI arguments
func GetCliArgs() (cli argsParsed, err error) {
rawCli := args{}
rawCli.Logging = false
arg.MustParse(&rawCli)
cli.args = rawCli
return cli, nil
}