-
Notifications
You must be signed in to change notification settings - Fork 1
/
cmd_vertical_top.go
47 lines (40 loc) · 994 Bytes
/
cmd_vertical_top.go
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
46
47
package main
import (
"github.com/spf13/cobra"
)
func init() {
RootCommand.AddCommand(verticalTopCommand)
verticalTopCommand.Flags().IntP("length", "n", -1, "Padding length")
verticalTopCommand.Flags().BoolP("write", "w", false, "Overwrite file")
verticalTopCommand.Flags().StringP("linefeed", "l", "\n", "Line feed")
}
var verticalTopCommand = &cobra.Command{
Use: "vertical-top",
Aliases: []string{"vt"},
Short: "Align vertical top command from file or stdin",
Run: func(cmd *cobra.Command, args []string) {
f := cmd.Flags()
n, err := f.GetInt("length")
if err != nil {
panic(err)
}
writeFile, err := f.GetBool("write")
if err != nil {
panic(err)
}
lf, err := f.GetString("linefeed")
if err != nil {
panic(err)
}
param := LogicVerticalAlignParam{
args: args,
length: n,
writeFile: writeFile,
lineFeed: lf,
f: AlignVerticalTop,
}
if err := LogicVerticalAlign(param); err != nil {
panic(err)
}
},
}