diff --git a/cmd/processor_rot13-encode.go b/cmd/processor_rot13.go similarity index 77% rename from cmd/processor_rot13-encode.go rename to cmd/processor_rot13.go index 765eec5..2b05cc4 100644 --- a/cmd/processor_rot13-encode.go +++ b/cmd/processor_rot13.go @@ -12,13 +12,13 @@ import ( ) func init() { - rootCmd.AddCommand(rot13EncodeCmd) + rootCmd.AddCommand(rot13Cmd) } -var rot13EncodeCmd = &cobra.Command{ - Use: "rot13-encode [string]", - Short: "Encode your text to ROT13", - Aliases: []string{"rot13", "rot13-enc"}, +var rot13Cmd = &cobra.Command{ + Use: "rot13 [string]", + Short: "Cipher/Decipher your text with ROT13 letter substitution", + Aliases: []string{"rot13-encode", "rot13-enc"}, Args: cobra.MaximumNArgs(1), RunE: func(cmd *cobra.Command, args []string) error { var err error @@ -40,7 +40,7 @@ var rot13EncodeCmd = &cobra.Command{ } flags := make([]processors.Flag, 0) - p := processors.ROT13Encode{} + p := processors.ROT13{} out, err = p.Transform(in, flags...) if err != nil { diff --git a/processors/processor.go b/processors/processor.go index 61718d2..7cb4fe7 100644 --- a/processors/processor.go +++ b/processors/processor.go @@ -48,7 +48,7 @@ var List = []list.Item{ Reverse{}, ReverseLines{}, ReverseLines{}, - ROT13Encode{}, + ROT13{}, SHA1{}, SHA224{}, SHA256{}, diff --git a/processors/rot.go b/processors/rot13.go similarity index 51% rename from processors/rot.go rename to processors/rot13.go index 6287f26..96e5cdb 100644 --- a/processors/rot.go +++ b/processors/rot13.go @@ -5,35 +5,36 @@ import ( "strings" ) -// ROT13Encode converts string to ROT13 encoding. -type ROT13Encode struct{} +// ROT13 converts string with ROT13 cypher. +// https://en.wikipedia.org/wiki/ROT13 +type ROT13 struct{} -func (p ROT13Encode) Name() string { - return "rot13-encode" +func (p ROT13) Name() string { + return "rot13" } -func (p ROT13Encode) Alias() []string { - return []string{"rot13", "rot13-enc"} +func (p ROT13) Alias() []string { + return []string{"rot13-encode", "rot13-enc"} } -func (p ROT13Encode) Transform(data []byte, _ ...Flag) (string, error) { +func (p ROT13) Transform(data []byte, _ ...Flag) (string, error) { return strings.Map(rot13, string(data)), nil } -func (p ROT13Encode) Flags() []Flag { +func (p ROT13) Flags() []Flag { return nil } -func (p ROT13Encode) Title() string { - title := "ROT13 Encode" +func (p ROT13) Title() string { + title := "ROT13 Letter Substitution" return fmt.Sprintf("%s (%s)", title, p.Name()) } -func (p ROT13Encode) Description() string { - return "Encode your text to ROT13" +func (p ROT13) Description() string { + return "Cipher/Decipher your text with ROT13 letter substitution" } -func (p ROT13Encode) FilterValue() string { +func (p ROT13) FilterValue() string { return p.Title() } diff --git a/processors/rot_test.go b/processors/rot13_test.go similarity index 84% rename from processors/rot_test.go rename to processors/rot13_test.go index 6810901..2d3c693 100644 --- a/processors/rot_test.go +++ b/processors/rot13_test.go @@ -5,7 +5,7 @@ import ( "testing" ) -func TestROT13Encode_Transform(t *testing.T) { +func TestROT13_Transform(t *testing.T) { type args struct { data []byte in1 []Flag @@ -36,7 +36,7 @@ func TestROT13Encode_Transform(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - p := ROT13Encode{} + p := ROT13{} got, err := p.Transform(tt.args.data, tt.args.in1...) if (err != nil) != tt.wantErr { t.Errorf("Transform() error = %v, wantErr %v", err, tt.wantErr) @@ -49,7 +49,7 @@ func TestROT13Encode_Transform(t *testing.T) { } } -func TestROT13Encode_Command(t *testing.T) { +func TestROT13_Command(t *testing.T) { test := struct { alias []string description string @@ -58,14 +58,14 @@ func TestROT13Encode_Command(t *testing.T) { name string title string }{ - alias: []string{"rot13", "rot13-enc"}, - description: "Encode your text to ROT13", - filterValue: "ROT13 Encode (rot13-encode)", + alias: []string{"rot13-encode", "rot13-enc"}, + description: "Cipher/Decipher your text with ROT13 letter substitution", + filterValue: "ROT13 Letter Substitution (rot13)", flags: nil, - name: "rot13-encode", - title: "ROT13 Encode (rot13-encode)", + name: "rot13", + title: "ROT13 Letter Substitution (rot13)", } - p := ROT13Encode{} + p := ROT13{} if got := p.Alias(); !reflect.DeepEqual(got, test.alias) { t.Errorf("Alias() = %v, want %v", got, test.alias) }