echo.go 489 B

1234567891011121314151617181920212223242526272829303132
  1. /* Simple 'echo' implementation. */
  2. package echo
  3. import (
  4. "fmt"
  5. "surdeus.su/core/cli/mtool"
  6. )
  7. var(
  8. del string
  9. eol = "\n"
  10. )
  11. func Run(flagSet *mtool.Flags) {
  12. var nflag bool
  13. flagSet.BoolVar(&nflag, "n", false, "Do not print new line character.")
  14. flagSet.StringVar(&del, "d", " ", "Delimiter of arguments")
  15. flagSet.Parse()
  16. args := flagSet.Args()
  17. l := len(args) - 1
  18. for i, s := range args {
  19. fmt.Print(s)
  20. if i!=l { fmt.Print(del) }
  21. }
  22. if !nflag {
  23. fmt.Print(eol)
  24. }
  25. }