Skip to content

Commit 6f55ee1

Browse files
authored
Revert "update!: moved all program elements in sub packages to root (#65)"
This reverts commit 4e0868e.
1 parent 4e0868e commit 6f55ee1

File tree

11 files changed

+245
-225
lines changed

11 files changed

+245
-225
lines changed

errors.go renamed to errors/errors.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
// This program is free software under MIT License.
33
// See the file LICENSE in this distribution for more details.
44

5-
package cliargs
5+
// Package errors contains the error structures that can occur during
6+
// command line argument parsing.
7+
package errors
68

79
import (
810
"fmt"
Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,117 +1,117 @@
1-
package cliargs_test
1+
package errors_test
22

33
import (
44
"fmt"
55
"reflect"
66
"testing"
77

88
"github.com/stretchr/testify/assert"
9-
"github.com/sttk/cliargs"
9+
"github.com/sttk/cliargs/errors"
1010
)
1111

1212
func TestErrors_OptionContainsInvalidChar(t *testing.T) {
13-
e := cliargs.OptionContainsInvalidChar{Option: "foo"}
13+
e := errors.OptionContainsInvalidChar{Option: "foo"}
1414
assert.Equal(t, e.Option, "foo")
1515
assert.Equal(t, e.GetOption(), "foo")
1616
assert.Equal(t, e.Error(), "OptionContainsInvalidChar{Option:foo}")
1717

18-
var ee cliargs.InvalidOption = e
18+
var ee errors.InvalidOption = e
1919
assert.Equal(t, ee.GetOption(), "foo")
2020
}
2121

2222
func TestErrors_UnconfiguredOption(t *testing.T) {
23-
e := cliargs.UnconfiguredOption{Option: "foo"}
23+
e := errors.UnconfiguredOption{Option: "foo"}
2424
assert.Equal(t, e.Option, "foo")
2525
assert.Equal(t, e.GetOption(), "foo")
2626
assert.Equal(t, e.Error(), "UnconfiguredOption{Option:foo}")
2727

28-
var ee cliargs.InvalidOption = e
28+
var ee errors.InvalidOption = e
2929
assert.Equal(t, ee.GetOption(), "foo")
3030
}
3131

3232
func TestErrors_OptionNeedsArg(t *testing.T) {
33-
e := cliargs.OptionNeedsArg{Option: "foo", StoreKey: "Foo"}
33+
e := errors.OptionNeedsArg{Option: "foo", StoreKey: "Foo"}
3434
assert.Equal(t, e.Option, "foo")
3535
assert.Equal(t, e.StoreKey, "Foo")
3636
assert.Equal(t, e.GetOption(), "foo")
3737
assert.Equal(t, e.Error(), "OptionNeedsArg{Option:foo,StoreKey:Foo}")
3838

39-
var ee cliargs.InvalidOption = e
39+
var ee errors.InvalidOption = e
4040
assert.Equal(t, ee.GetOption(), "foo")
4141
}
4242

4343
func TestErrors_OptionTakesNoArg(t *testing.T) {
44-
e := cliargs.OptionTakesNoArg{Option: "foo", StoreKey: "Foo"}
44+
e := errors.OptionTakesNoArg{Option: "foo", StoreKey: "Foo"}
4545
assert.Equal(t, e.Option, "foo")
4646
assert.Equal(t, e.StoreKey, "Foo")
4747
assert.Equal(t, e.GetOption(), "foo")
4848
assert.Equal(t, e.Error(), "OptionTakesNoArg{Option:foo,StoreKey:Foo}")
4949

50-
var ee cliargs.InvalidOption = e
50+
var ee errors.InvalidOption = e
5151
assert.Equal(t, ee.GetOption(), "foo")
5252
}
5353

5454
func TestErrors_OptionIsNotArray(t *testing.T) {
55-
e := cliargs.OptionIsNotArray{Option: "foo", StoreKey: "Foo"}
55+
e := errors.OptionIsNotArray{Option: "foo", StoreKey: "Foo"}
5656
assert.Equal(t, e.Option, "foo")
5757
assert.Equal(t, e.StoreKey, "Foo")
5858
assert.Equal(t, e.GetOption(), "foo")
5959
assert.Equal(t, e.Error(), "OptionIsNotArray{Option:foo,StoreKey:Foo}")
6060

61-
var ee cliargs.InvalidOption = e
61+
var ee errors.InvalidOption = e
6262
assert.Equal(t, ee.GetOption(), "foo")
6363
}
6464

6565
func TestErrors_StoreKeyIsDuplicated(t *testing.T) {
66-
e := cliargs.StoreKeyIsDuplicated{StoreKey: "Foo", Name: "foo"}
66+
e := errors.StoreKeyIsDuplicated{StoreKey: "Foo", Name: "foo"}
6767

6868
assert.Equal(t, e.Name, "foo")
6969
assert.Equal(t, e.StoreKey, "Foo")
7070
assert.Equal(t, e.GetOption(), "foo")
7171
assert.Equal(t, e.Error(), "StoreKeyIsDuplicated{StoreKey:Foo,Name:foo}")
7272

73-
var ee cliargs.InvalidOption = e
73+
var ee errors.InvalidOption = e
7474
assert.Equal(t, ee.GetOption(), "foo")
7575
}
7676

7777
func TestErrors_ConfigIsArrayButHasNoArg(t *testing.T) {
78-
e := cliargs.ConfigIsArrayButHasNoArg{StoreKey: "Foo", Name: "foo"}
78+
e := errors.ConfigIsArrayButHasNoArg{StoreKey: "Foo", Name: "foo"}
7979

8080
assert.Equal(t, e.Name, "foo")
8181
assert.Equal(t, e.StoreKey, "Foo")
8282
assert.Equal(t, e.GetOption(), "foo")
8383
assert.Equal(t, e.Error(), "ConfigIsArrayButHasNoArg{StoreKey:Foo,Name:foo}")
8484

85-
var ee cliargs.InvalidOption = e
85+
var ee errors.InvalidOption = e
8686
assert.Equal(t, ee.GetOption(), "foo")
8787
}
8888

8989
func TestErrors_ConfigHasDefaultsButHasNoArg(t *testing.T) {
90-
e := cliargs.ConfigHasDefaultsButHasNoArg{StoreKey: "Foo", Name: "foo"}
90+
e := errors.ConfigHasDefaultsButHasNoArg{StoreKey: "Foo", Name: "foo"}
9191

9292
assert.Equal(t, e.Name, "foo")
9393
assert.Equal(t, e.StoreKey, "Foo")
9494
assert.Equal(t, e.GetOption(), "foo")
9595
assert.Equal(t, e.Error(), "ConfigHasDefaultsButHasNoArg{StoreKey:Foo,Name:foo}")
9696

97-
var ee cliargs.InvalidOption = e
97+
var ee errors.InvalidOption = e
9898
assert.Equal(t, ee.GetOption(), "foo")
9999
}
100100

101101
func TestErrors_OptionNameIsDuplicated(t *testing.T) {
102-
e := cliargs.OptionNameIsDuplicated{StoreKey: "Foo", Name: "foo"}
102+
e := errors.OptionNameIsDuplicated{StoreKey: "Foo", Name: "foo"}
103103

104104
assert.Equal(t, e.Name, "foo")
105105
assert.Equal(t, e.StoreKey, "Foo")
106106
assert.Equal(t, e.GetOption(), "foo")
107107
assert.Equal(t, e.Error(), "OptionNameIsDuplicated{StoreKey:Foo,Name:foo}")
108108

109-
var ee cliargs.InvalidOption = e
109+
var ee errors.InvalidOption = e
110110
assert.Equal(t, ee.GetOption(), "foo")
111111
}
112112

113113
func TestErrors_OptionArgIsInvalid(t *testing.T) {
114-
e := cliargs.OptionArgIsInvalid{
114+
e := errors.OptionArgIsInvalid{
115115
StoreKey: "Foo", Option: "foo", OptArg: "xx", TypeKind: reflect.Int,
116116
Cause: fmt.Errorf("type error")}
117117

@@ -122,16 +122,16 @@ func TestErrors_OptionArgIsInvalid(t *testing.T) {
122122
assert.Equal(t, e.GetOption(), "foo")
123123
assert.Equal(t, e.Error(), "OptionArgIsInvalid{StoreKey:Foo,Option:foo,OptArg:xx,TypeKind:int,Cause:type error}")
124124

125-
var ee cliargs.InvalidOption = e
125+
var ee errors.InvalidOption = e
126126
assert.Equal(t, ee.GetOption(), "foo")
127127
}
128128

129129
func TestErrors_OptionStoreIsNotChangeable(t *testing.T) {
130-
e := cliargs.OptionStoreIsNotChangeable{}
130+
e := errors.OptionStoreIsNotChangeable{}
131131
assert.Equal(t, e.Error(), "OptionStoreIsNotChangeable{}")
132132
}
133133

134134
func TestErrors_BadFieldType(t *testing.T) {
135-
e := cliargs.BadFieldType{Option: "foo", Field: "Foo", Type: reflect.TypeOf(0)}
135+
e := errors.BadFieldType{Option: "foo", Field: "Foo", Type: reflect.TypeOf(0)}
136136
assert.Equal(t, e.Error(), "BadFieldType{Option:foo,Field:Foo,Type:int}")
137137
}

0 commit comments

Comments
 (0)