github.com/BarDweller/libpak@v0.0.0-20230630201634-8dd5cfc15ec9/cmd/update-package-dependency/main.go (about) 1 /* 2 * Copyright 2018-2020 the original author or authors. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * https://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package main 18 19 import ( 20 "fmt" 21 "log" 22 "os" 23 24 "github.com/spf13/pflag" 25 26 "github.com/BarDweller/libpak/carton" 27 ) 28 29 func main() { 30 p := carton.PackageDependency{} 31 32 flagSet := pflag.NewFlagSet("Update Package Dependency", pflag.ExitOnError) 33 flagSet.StringVar(&p.BuilderPath, "builder-toml", "", "path to builder.toml") 34 flagSet.StringVar(&p.BuildpackPath, "buildpack-toml", "", "path to buildpack.toml") 35 flagSet.StringVar(&p.ID, "id", "", "the id of the dependency") 36 flagSet.StringVar(&p.PackagePath, "package-toml", "", "path to package.toml") 37 flagSet.StringVar(&p.Version, "version", "", "the new version of the dependency") 38 39 if err := flagSet.Parse(os.Args[1:]); err != nil { 40 log.Fatal(fmt.Errorf("unable to parse flags\n%w", err)) 41 } 42 43 if p.BuilderPath == "" && p.BuildpackPath == "" && p.PackagePath == "" { 44 log.Fatal("builder-toml, buildpack-toml, or package-toml must be set") 45 } 46 47 if p.ID == "" { 48 log.Fatal("id must be set") 49 } 50 51 if p.Version == "" { 52 log.Fatal("version must be set") 53 } 54 55 p.Update() 56 }