src

Go monorepo.
git clone git://code.dwrz.net/src
Log | Files | Refs

add.go (612B)


      1 package help
      2 
      3 import (
      4 	"fmt"
      5 	"sort"
      6 	"strings"
      7 
      8 	"code.dwrz.net/src/pkg/dqs/category"
      9 )
     10 
     11 var add = strings.ReplaceAll(portions, "%s", "add")
     12 
     13 func Add() string {
     14 	var str strings.Builder
     15 
     16 	str.WriteString(add)
     17 
     18 	var abbreviations = [][2]string{}
     19 	for abbreviation, name := range category.Abbreviations {
     20 		abbreviations = append(abbreviations, [2]string{
     21 			name, abbreviation,
     22 		})
     23 	}
     24 
     25 	sort.Slice(abbreviations, func(i, j int) bool {
     26 		return abbreviations[i][0] < abbreviations[j][0]
     27 	})
     28 
     29 	for _, a := range abbreviations {
     30 		str.WriteString(fmt.Sprintf("%-5s %s\n", a[1], a[0]))
     31 	}
     32 
     33 	return str.String()
     34 }