Skip to content

Commit

Permalink
Merge pull request #18 from reeflective/dev
Browse files Browse the repository at this point in the history
Fixes and updates
  • Loading branch information
maxlandon authored Apr 19, 2023
2 parents f0b92fd + 4c403e7 commit 2506a24
Show file tree
Hide file tree
Showing 72 changed files with 1,293 additions and 844 deletions.
48 changes: 24 additions & 24 deletions camelcase.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,37 +42,37 @@ const (
//
// Examples
//
// "" => [""]
// "lowercase" => ["lowercase"]
// "Class" => ["Class"]
// "MyClass" => ["My", "Class"]
// "MyC" => ["My", "C"]
// "HTML" => ["HTML"]
// "PDFLoader" => ["PDF", "Loader"]
// "AString" => ["A", "String"]
// "SimpleXMLParser" => ["Simple", "XML", "Parser"]
// "vimRPCPlugin" => ["vim", "RPC", "Plugin"]
// "GL11Version" => ["GL11", "Version"]
// "99Bottles" => ["99", "Bottles"]
// "May5" => ["May5"]
// "BFG9000" => ["BFG9000"]
// "BöseÜberraschung" => ["Böse", "Überraschung"]
// "Two spaces" => ["Two", " ", "spaces"]
// "BadUTF8\xe2\xe2\xa1" => ["BadUTF8\xe2\xe2\xa1"]
// "" => [""]
// "lowercase" => ["lowercase"]
// "Class" => ["Class"]
// "MyClass" => ["My", "Class"]
// "MyC" => ["My", "C"]
// "HTML" => ["HTML"]
// "PDFLoader" => ["PDF", "Loader"]
// "AString" => ["A", "String"]
// "SimpleXMLParser" => ["Simple", "XML", "Parser"]
// "vimRPCPlugin" => ["vim", "RPC", "Plugin"]
// "GL11Version" => ["GL11", "Version"]
// "99Bottles" => ["99", "Bottles"]
// "May5" => ["May5"]
// "BFG9000" => ["BFG9000"]
// "BöseÜberraschung" => ["Böse", "Überraschung"]
// "Two spaces" => ["Two", " ", "spaces"]
// "BadUTF8\xe2\xe2\xa1" => ["BadUTF8\xe2\xe2\xa1"]
//
// Splitting rules
//
// 1) If string is not valid UTF-8, return it without splitting as
// 1. If string is not valid UTF-8, return it without splitting as
// single item array.
// 2) Assign all unicode characters into one of 4 sets: lower case
// 2. Assign all unicode characters into one of 4 sets: lower case
// letters, upper case letters, numbers, and all other characters.
// 3) Iterate through characters of string, introducing splits
// 3. Iterate through characters of string, introducing splits
// between adjacent characters that belong to different sets.
// 4) Iterate through array of split strings, and if a given string
// 4. Iterate through array of split strings, and if a given string
// is upper case:
// if subsequent string is lower case:
// move last character of upper case string to beginning of
// lower case string
// if subsequent string is lower case:
// move last character of upper case string to beginning of
// lower case string
func split(src string) (entries []string) {
// don't split invalid utf8
if !utf8.ValidString(src) {
Expand Down
2 changes: 1 addition & 1 deletion camelcase_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//
// The MIT License (MIT)
//
// Copyright (c) 2015 Fatih Arslan
// # Copyright (c) 2015 Fatih Arslan
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of
// this software and associated documentation files (the "Software"), to deal in
Expand Down
Binary file modified example/example
Binary file not shown.
4 changes: 2 additions & 2 deletions example/opts/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ type Machines string

// Complete provides user@host completions.
func (m *Machines) Complete(ctx carapace.Context) carapace.Action {
if strings.Contains(ctx.CallbackValue, "@") {
prefix := strings.SplitN(ctx.CallbackValue, "@", 2)[0]
if strings.Contains(ctx.Value, "@") {
prefix := strings.SplitN(ctx.Value, "@", 2)[0]
return net.ActionHosts().Invoke(ctx).Prefix(prefix + "@").ToA()
} else {
return net.ActionHosts()
Expand Down
33 changes: 14 additions & 19 deletions flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,27 @@
// package main
//
// import (
// "github.com/reeflective/flags/example/commands"
//
// "github.com/reeflective/flags"
// genflags "github.com/reeflective/flags/gen/flags"
// "github.com/reeflective/flags/example/commands"
//
// "github.com/reeflective/flags/validator"
// "github.com/reeflective/flags/gen/completions"
// )
// "github.com/reeflective/flags"
// genflags "github.com/reeflective/flags/gen/flags"
//
// "github.com/reeflective/flags/validator"
// "github.com/reeflective/flags/gen/completions"
//
// func main() {
// var opts []flags.OptFunc
// )
//
// opts = append(opts, flags.Validator(validator.New()))
// func main() {
// var opts []flags.OptFunc
//
// rootData := &commands.Root{}
// rootCmd := genflags.Generate(rootData, opts...)
// opts = append(opts, flags.Validator(validator.New()))
//
// comps, _ := completions.Generate(rootCmd, rootData, nil)
// }
// rootData := &commands.Root{}
// rootCmd := genflags.Generate(rootData, opts...)
//
// comps, _ := completions.Generate(rootCmd, rootData, nil)
// }
//
// 2) Global parsing options (base) ------------------------------------------------------
//
Expand Down Expand Up @@ -64,7 +65,6 @@
// tag attached to them. This is because by default the library does not considers untagged field anymore.
// func ParseAll()
//
//
// 3) Special parsing options/functions---------------------------------------------------
//
// ValidateFunc describes a validation func, that takes string val for flag from command line,
Expand All @@ -73,24 +73,19 @@
//
// type ValidateFunc func(val string, field reflect.StructField, data interface{}) error
//
//
// Validator sets validator function for flags.
// Check existing validators in flags/validator and flags/validator/govalidator packages.
//
// func Validator(val ValidateFunc)
//
//
// FlagFunc is a generic function that can be applied to each
// value that will end up being a flags *Flag, so that users
// can perform more arbitrary operations on each, such as checking
// for completer implementations, bind to viper configurations, etc.
//
// type FlagFunc func(flag string, tag tag.MultiTag, val reflect.Value) error
//
//
// FlagHandler sets the handler function for flags, in order to perform arbitrary
// operations on the value of the flag identified by the <flag> name parameter of FlagFunc.
//
// func FlagHandler(val FlagFunc)
//
package flags
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ require (
github.com/go-playground/validator/v10 v10.11.1
github.com/rsteube/carapace v0.30.0
github.com/rsteube/carapace-bin v0.19.0
github.com/spf13/cobra v1.6.1
github.com/spf13/cobra v1.7.0
github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.8.0
)
Expand All @@ -25,4 +25,4 @@ require (
gopkg.in/yaml.v3 v3.0.1 // indirect
)

replace github.com/rsteube/carapace v0.30.0 => github.com/reeflective/carapace v0.25.2-0.20230106225838-382407e213d4
replace github.com/rsteube/carapace v0.30.0 => github.com/reeflective/carapace v0.25.2-0.20230416191807-fc9b8c3aa6f6
9 changes: 4 additions & 5 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ github.com/go-playground/universal-translator v0.18.0 h1:82dyy6p4OuJq4/CByFNOn/j
github.com/go-playground/universal-translator v0.18.0/go.mod h1:UvRDBj+xPUEGrFYl+lu/H90nyDXpg0fqeB/AQUGNTVA=
github.com/go-playground/validator/v10 v10.11.1 h1:prmOlTVv+YjZjmRmNSF3VmspqJIxJWXmqUsHwfTRRkQ=
github.com/go-playground/validator/v10 v10.11.1/go.mod h1:i+3WkQ1FvaUjjxh1kSvIA4dMGDBiPU55YFDl0WbKdWU=
github.com/inconshreveable/mousetrap v1.0.1/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
Expand All @@ -29,16 +28,16 @@ github.com/leodido/go-urn v1.2.1/go.mod h1:zt4jvISO2HfUBqxjfIshjdMTYS56ZS/qv49ic
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/reeflective/carapace v0.25.2-0.20230106225838-382407e213d4 h1:FTPSPEnA0dklTQm61gv7gtYh85/WFqeJSSENa7BCdxk=
github.com/reeflective/carapace v0.25.2-0.20230106225838-382407e213d4/go.mod h1:/ALYHicIpak6TjQnKl7HupclqJydy2LQb6CkawYBxDo=
github.com/reeflective/carapace v0.25.2-0.20230416191807-fc9b8c3aa6f6 h1:3HHTRiXvaEz8iACxwlOBc9jHDYxYNvW60U63Q97/31w=
github.com/reeflective/carapace v0.25.2-0.20230416191807-fc9b8c3aa6f6/go.mod h1:jkLt41Ne2TD2xPuMdX/2O05Smhy8vMgG7O2TYvC0yOc=
github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
github.com/rogpeppe/go-internal v1.8.0 h1:FCbCCtXNOY3UtUuHUYaghJg4y7Fd14rXifAYUAtL9R8=
github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE=
github.com/rsteube/carapace-bin v0.19.0 h1:pmWOrtO0Fz4G+55OKHjjA4ihIKZKzDZh3Z8X1pY8IBk=
github.com/rsteube/carapace-bin v0.19.0/go.mod h1:yAF4advL85gx7ZFxYYsJu8Rgp2akz4TqvD6M0Bg0VGc=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/spf13/cobra v1.6.1 h1:o94oiPyS4KD1mPy2fmcYYHHfCxLqYjJOhGsCHFZtEzA=
github.com/spf13/cobra v1.6.1/go.mod h1:IOw/AERYS7UzyrGinqmz6HLUo219MORXGxhbaJUqzrY=
github.com/spf13/cobra v1.7.0 h1:hyqWnYt1ZQShIddO5kBpj3vu05/++x6tJ6dg8EC572I=
github.com/spf13/cobra v1.7.0/go.mod h1:uLxZILRyS/50WlhOIKD7W6V5bgeIt+4sICxh6uRMrb0=
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
Expand Down
1 change: 1 addition & 0 deletions vendor/github.com/rsteube/carapace/.dockerignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 40 additions & 0 deletions vendor/github.com/rsteube/carapace/.goreleaser.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 2506a24

Please sign in to comment.