feat(commands): refactor and add more commands

This commit is contained in:
verse91
2026-04-09 23:30:16 +07:00
parent 76458ce52e
commit f4816d2b5f
31 changed files with 546 additions and 110 deletions
+17
View File
@@ -0,0 +1,17 @@
package view
import (
"github.com/versenilvis/iris/commands/core"
)
func init() {
core.Register(&core.Spec{
Name: "cat",
Description: "concatenate and print",
Generator: core.FileGenerator(),
Options: []core.Option{
{Name: "-n", Description: "number lines"},
{Name: "-b", Description: "number non-blank"},
},
})
}
+16
View File
@@ -0,0 +1,16 @@
package view
import (
"github.com/versenilvis/iris/commands/core"
)
func init() {
core.Register(&core.Spec{
Name: "head",
Description: "output first lines of file",
Generator: core.FileGenerator(),
Options: []core.Option{
{Name: "-n", Description: "number of lines"},
},
})
}
+13
View File
@@ -0,0 +1,13 @@
package view
import (
"github.com/versenilvis/iris/commands/core"
)
func init() {
core.Register(&core.Spec{
Name: "less",
Description: "view file contents (scrollable)",
Generator: core.FileGenerator(),
})
}
+17
View File
@@ -0,0 +1,17 @@
package view
import (
"github.com/versenilvis/iris/commands/core"
)
func init() {
core.Register(&core.Spec{
Name: "tail",
Description: "output last lines of file",
Generator: core.FileGenerator(),
Options: []core.Option{
{Name: "-n", Description: "number of lines"},
{Name: "-f", Description: "follow (live updates)"},
},
})
}