Skip to content
Snippets Groups Projects
Select Git revision
  • ba4ce5b99c3136e97f35a8e65adccc286db7244b
  • master default protected
  • 1.31
  • 4.24.3
  • 4.24.2
  • 4.24.1
  • 4.24.0
  • 4.23.6
  • 4.23.5
  • 4.23.4
  • 4.23.3
  • 4.23.2
  • 4.23.1
  • 4.23.0
  • 4.22.3
  • 4.22.2
  • 4.22.1
  • 4.22.0
  • 4.21.0
  • 4.20.1
  • 4.20.0
  • 4.19.0
  • 4.18.0
23 results

popper.mjs

Blame
  • flag_test.go 935 B
    // Copyright 2022 schukai GmbH
    // SPDX-License-Identifier: AGPL-3.0-or-later
    
    package xflags
    
    import (
    	"fmt"
    	"github.com/stretchr/testify/assert"
    	"testing"
    )
    
    func TestWrongDefinitionType(t *testing.T) {
    	c := New("root", 2)
    	c.Parse([]string{"test"})
    	c.Execute()
    	assert.True(t, c.HasErrors())
    }
    
    type testExecuteCommandStruct struct {
    	Command1 struct {
    	} `command:"command1" description:"Command 1" callback:"command1Callback" `
    	Command2 struct {
    		Command3 struct {
    		} `command:"command3" description:"Command 3" callback:"command3Callback" `
    	} `command:"command2" description:"Command 2" callback:"command2Callback" `
    }
    
    func (c *testExecuteCommandStruct) command1Callback(args []string) {
    	fmt.Println("command1Callback", args)
    }
    
    func TestExecute1(t *testing.T) {
    	c := New("root", testExecuteCommandStruct{})
    	c.Parse([]string{"root", "command2", "command3", "commandX"})
    	c.Execute()
    	assert.False(t, c.HasErrors())
    }