Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: alecthomas/kong
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.8.1
Choose a base ref
...
head repository: alecthomas/kong
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v1.9.0
Choose a head ref
  • 9 commits
  • 27 files changed
  • 5 contributors

Commits on Feb 17, 2025

  1. ci: Test with Go 1.23 and 1.24 (#502)

    In CI, test with Go 1.23 and 1.24,
    and upgrade the Hermit-managed Go and golangci-lint to latest versions.
    
    The new golangci-lint had a number of warnings and minor issues
    that were either fixed or opted-out of.
    abhinav authored Feb 17, 2025
    Configuration menu
    Copy the full SHA
    9f71a49 View commit details
    Browse the repository at this point in the history
  2. chore(deps): update module github.com/alecthomas/kong to v1.8.1 (#503)

    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
    renovate[bot] authored Feb 17, 2025
    Configuration menu
    Copy the full SHA
    7f94c90 View commit details
    Browse the repository at this point in the history
  3. feat: Support singleton providers (#501)

    * feat: Support singleton providers
    
    This change adds support for provider functions that are
    not reinvoked even if requested by multiple other providers.
    Instead, their value is cached and reused between invocations.
    
    To make this possible, we change how bindings are stored:
    instead of just a function reference, we now store a binding object
    which records whether the binding is a singleton,
    and records the resolved singleton value (if any).
    
    Resolves #500
    
    * refac(bindings): hide singleton status
    
    Don't require callAnyFunction to be aware of
    whether a binding is a singleton or not.
    abhinav authored Feb 17, 2025
    Configuration menu
    Copy the full SHA
    3b9af5b View commit details
    Browse the repository at this point in the history
  4. feat: Allow ignoring fields from embedded structs (#499)

    If a field in a struct is ignored with `kong:"-"`, any embedded fields
    with the same name are also ignored. This allows an outer struct to
    remove flags from an embedded struct by redefining it and adding a kong
    ignore tag.
    camh- authored Feb 17, 2025
    Configuration menu
    Copy the full SHA
    300cba8 View commit details
    Browse the repository at this point in the history

Commits on Feb 26, 2025

  1. Configuration menu
    Copy the full SHA
    0c495e4 View commit details
    Browse the repository at this point in the history

Commits on Mar 7, 2025

  1. feat: Allow kong.Path to describe remaining unparsed args (#472)

    As Kong traces a sequence of command line arguments, it parses them and appends them to the parsed `Path` sequence. For each element in `Path`, these is a corresponding sequence of unparsed arguments. This change enables `Path` to yield these.
    
    I have a package that uses Kong's hooks to instrument Kong applications (to monitor usage, reliability, etc of internal tools). I would like to instrument the commandline arguments as well.
    
    This change would enable it to work roughly as follows:
    ```golang
    func (Foo) BeforeApply(app *kong.Kong, ctx *kong.Context, t *Tracker) error {
    	command := []string{ctx.Model.Name}
    	var args  []string
    
    	for _, path := range ctx.Path {
    		if path.Command != nil {
    			command = append(command, path.Command.Name)
    			args = path.Remainder()
    		}
    	}
    
    	app.Exit = t.exit(app.Exit)
    
    	t.WithCommand(strings.Join(command, " ")).WithArgs(args)
    	return nil
    }
    ```
    boblail authored Mar 7, 2025
    Configuration menu
    Copy the full SHA
    5b36573 View commit details
    Browse the repository at this point in the history

Commits on Mar 8, 2025

  1. Configuration menu
    Copy the full SHA
    73db2e8 View commit details
    Browse the repository at this point in the history

Commits on Mar 11, 2025

  1. feat: Allow Kong to exit with semantic exit codes (#507)

    * feat: Allow Kong to exit with semantic exit codes
    
    At Block, we've instrumented a number of commandline tools and set SLOs on some tools' reliability. To do that effectively, we had to partition usage errors from reliability issues. We looked at [prior art](https://github.com/square/exit?tab=readme-ov-file#reserved-codes-and-prior-art) and, taking inspiration from HTTP, defined [a set of semantic exit codes](https://github.com/square/exit?tab=readme-ov-file#about) in ranges: 80-99 for user errors, 100-119 for system errors.
    
    We've been wrapping errors in `exit.Error` at whatever level of the stack can tell which class an error is and unwrapping them at exit (`os.Exit(exit.FromError(err))`).
    
    This adds support for semantic exit codes to Kong, to `FatalIfErrorf`, which is used internally by `kong.Parse` and often used in Kong applications.
    
    * feat: Exit 80 (Usage Error) when usage is syntactically or semantically invalid
    
    * refactor: Always exit 80 (Usage Error) on a `ParseError` but don't wrap errors from hooks in `ParseError`
    boblail authored Mar 11, 2025
    Configuration menu
    Copy the full SHA
    a86adbb View commit details
    Browse the repository at this point in the history
  2. refactor: ParseError can carry an exit code

    Reinstated use of ParseError for all error paths so as to retain existing semantics.
    alecthomas committed Mar 11, 2025
    Configuration menu
    Copy the full SHA
    3d03233 View commit details
    Browse the repository at this point in the history
Loading