MCPcopy
hub / github.com/urfave/cli / TestPersistentFlag

Function TestPersistentFlag

command_test.go:3636–3747  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

3634}
3635
3636func TestPersistentFlag(t *testing.T) {
3637 var topInt, topPersistentInt, subCommandInt, appOverrideInt int64
3638 var appFlag string
3639 var appRequiredFlag string
3640 var appOverrideCmdInt int64
3641 var appSliceFloat64 []float64
3642 var persistentCommandSliceInt []int64
3643 var persistentFlagActionCount int64
3644
3645 cmd := &Command{
3646 Flags: []Flag{
3647 &StringFlag{
3648 Name: "persistentCommandFlag",
3649 Destination: &appFlag,
3650 Action: func(context.Context, *Command, string) error {
3651 persistentFlagActionCount++
3652 return nil
3653 },
3654 },
3655 &Int64SliceFlag{
3656 Name: "persistentCommandSliceFlag",
3657 Destination: &persistentCommandSliceInt,
3658 },
3659 &FloatSliceFlag{
3660 Name: "persistentCommandFloatSliceFlag",
3661 Value: []float64{11.3, 12.5},
3662 },
3663 &Int64Flag{
3664 Name: "persistentCommandOverrideFlag",
3665 Destination: &appOverrideInt,
3666 },
3667 &StringFlag{
3668 Name: "persistentRequiredCommandFlag",
3669 Required: true,
3670 Destination: &appRequiredFlag,
3671 },
3672 },
3673 Commands: []*Command{
3674 {
3675 Name: "cmd",
3676 Flags: []Flag{
3677 &Int64Flag{
3678 Name: "cmdFlag",
3679 Destination: &topInt,
3680 Local: true,
3681 },
3682 &Int64Flag{
3683 Name: "cmdPersistentFlag",
3684 Destination: &topPersistentInt,
3685 },
3686 &Int64Flag{
3687 Name: "paof",
3688 Aliases: []string{"persistentCommandOverrideFlag"},
3689 Destination: &appOverrideCmdInt,
3690 Local: true,
3691 },
3692 },
3693 Commands: []*Command{

Callers

nothing calls this directly

Calls 3

FloatSliceMethod · 0.95
RunMethod · 0.95
buildTestContextFunction · 0.85

Tested by

no test coverage detected