1package pflag
2
3import (
4	"fmt"
5	"strconv"
6)
7
8// -- int8 Value
9type int8Value int8
10
11func newInt8Value(val int8, p *int8) *int8Value {
12	*p = val
13	return (*int8Value)(p)
14}
15
16func (i *int8Value) Set(s string) error {
17	v, err := strconv.ParseInt(s, 0, 8)
18	*i = int8Value(v)
19	return err
20}
21
22func (i *int8Value) String() string { return fmt.Sprintf("%v", *i) }
23
24// Int8Var defines an int8 flag with specified name, default value, and usage string.
25// The argument p points to an int8 variable in which to store the value of the flag.
26func (f *FlagSet) Int8Var(p *int8, name string, value int8, usage string) {
27	f.VarP(newInt8Value(value, p), name, "", usage)
28}
29
30// Like Int8Var, but accepts a shorthand letter that can be used after a single dash.
31func (f *FlagSet) Int8VarP(p *int8, name, shorthand string, value int8, usage string) {
32	f.VarP(newInt8Value(value, p), name, shorthand, usage)
33}
34
35// Int8Var defines an int8 flag with specified name, default value, and usage string.
36// The argument p points to an int8 variable in which to store the value of the flag.
37func Int8Var(p *int8, name string, value int8, usage string) {
38	CommandLine.VarP(newInt8Value(value, p), name, "", usage)
39}
40
41// Like Int8Var, but accepts a shorthand letter that can be used after a single dash.
42func Int8VarP(p *int8, name, shorthand string, value int8, usage string) {
43	CommandLine.VarP(newInt8Value(value, p), name, shorthand, usage)
44}
45
46// Int8 defines an int8 flag with specified name, default value, and usage string.
47// The return value is the address of an int8 variable that stores the value of the flag.
48func (f *FlagSet) Int8(name string, value int8, usage string) *int8 {
49	p := new(int8)
50	f.Int8VarP(p, name, "", value, usage)
51	return p
52}
53
54// Like Int8, but accepts a shorthand letter that can be used after a single dash.
55func (f *FlagSet) Int8P(name, shorthand string, value int8, usage string) *int8 {
56	p := new(int8)
57	f.Int8VarP(p, name, shorthand, value, usage)
58	return p
59}
60
61// Int8 defines an int8 flag with specified name, default value, and usage string.
62// The return value is the address of an int8 variable that stores the value of the flag.
63func Int8(name string, value int8, usage string) *int8 {
64	return CommandLine.Int8P(name, "", value, usage)
65}
66
67// Like Int8, but accepts a shorthand letter that can be used after a single dash.
68func Int8P(name, shorthand string, value int8, usage string) *int8 {
69	return CommandLine.Int8P(name, shorthand, value, usage)
70}
71