mirror of
https://github.com/thunderbrewhq/binana.git
synced 2026-05-03 13:03:54 +00:00
feat(bna): implement fix-labels command
The fix-labels command will fix a symbol file by automatically renaming labels matching a certain regex, and looking for the captured parameter in a "fixlist" i.e. a newline delimited list of OG names.
This commit is contained in:
parent
d020e6ba36
commit
cbb42eb953
6 changed files with 145 additions and 4 deletions
37
go/app/cmd/fix_labels/fix_labels.go
Normal file
37
go/app/cmd/fix_labels/fix_labels.go
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
package fix_labels
|
||||
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/thunderbrewhq/binana/go/app"
|
||||
"github.com/thunderbrewhq/binana/go/app/cmd/root"
|
||||
"github.com/thunderbrewhq/binana/go/app/util"
|
||||
)
|
||||
|
||||
var fix_labels_cmd = cobra.Command{
|
||||
Use: "fix-labels fixlist capture-regex fix-pattern",
|
||||
Args: cobra.MinimumNArgs(3),
|
||||
Short: "quickly edit symbols by regex matching tokens against a list of known good symbols",
|
||||
Run: run_fix_labels_cmd,
|
||||
}
|
||||
|
||||
func init() {
|
||||
f := fix_labels_cmd.Flags()
|
||||
f.StringP("symbols", "s", "", "optional: specify a file to read from instead of stdin")
|
||||
root.RootCmd.AddCommand(&fix_labels_cmd)
|
||||
}
|
||||
|
||||
func run_fix_labels_cmd(cmd *cobra.Command, args []string) {
|
||||
f := cmd.Flags()
|
||||
var (
|
||||
err error
|
||||
params util.FixLabelsParams
|
||||
)
|
||||
params.Input, err = f.GetString("symbols")
|
||||
if err != nil {
|
||||
app.Fatal(err)
|
||||
}
|
||||
params.FixList = args[0]
|
||||
params.Capture = args[1]
|
||||
params.FixPattern = args[2]
|
||||
util.FixLabels(¶ms)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue