// SPDX-FileCopyrightText: Copyright The Lima Authors1// SPDX-License-Identifier: Apache-2.023// SPDX-FileCopyrightText: Copyright (c) 2017 Mike Farah45// This file has been adapted from https://github.com/mikefarah/yq/blob/v4.47.1/yq.go67package yq89import (10"os"11"path/filepath"12"strings"1314command "github.com/mikefarah/yq/v4/cmd"15)1617func main() {18cmd := command.New()19args := os.Args[1:]20_, _, err := cmd.Find(args)21if err != nil && args[0] != "__complete" {22// default command when nothing matches...23newArgs := []string{"eval"}24cmd.SetArgs(append(newArgs, os.Args[1:]...))25}26code := 027if err := cmd.Execute(); err != nil {28code = 129}30os.Exit(code)31}3233// MaybeRunYQ runs as `yq` if the program name or first argument is `yq`.34// Only returns to caller if os.Args doesn't contain a `yq` command.35func MaybeRunYQ() {36progName := filepath.Base(os.Args[0])37// remove all extensions, so we match "yq.lima.exe"38progName, _, _ = strings.Cut(progName, ".")39if progName == "yq" {40main()41}42if len(os.Args) > 1 && os.Args[1] == "yq" {43os.Args = os.Args[1:]44main()45}46}474849