github.com/jdhenke/godel@v0.0.0-20161213181855-abeb3861bf0d/cmd/godel/cmd.go (about)

     1  // Copyright 2016 Palantir Technologies, Inc.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  package godel
    16  
    17  import (
    18  	"github.com/nmiyake/pkg/dirs"
    19  	"github.com/palantir/pkg/cli"
    20  	"github.com/palantir/pkg/cli/flag"
    21  
    22  	"github.com/palantir/godel/cmd"
    23  	"github.com/palantir/godel/layout"
    24  )
    25  
    26  const packageParam = "package"
    27  
    28  var Version = "unspecified"
    29  
    30  func VersionCommand() cli.Command {
    31  	return cli.Command{
    32  		Name:  "version",
    33  		Usage: "Print the version",
    34  		Action: func(ctx cli.Context) error {
    35  			ctx.Println(layout.AppName, "version", Version)
    36  			return nil
    37  		},
    38  	}
    39  }
    40  
    41  func InstallCommand() cli.Command {
    42  	return cli.Command{
    43  		Name:  "install",
    44  		Usage: "Install gödel from a local tgz file",
    45  		Flags: []flag.Flag{
    46  			flag.StringParam{
    47  				Name:  packageParam,
    48  				Usage: "path to tgz of gödel distribution to install",
    49  			},
    50  		},
    51  		Action: func(ctx cli.Context) error {
    52  			wd, err := dirs.GetwdEvalSymLinks()
    53  			if err != nil {
    54  				return err
    55  			}
    56  			return NewInstall(wd, ctx.String(packageParam), ctx.App.Stdout)
    57  		},
    58  	}
    59  }
    60  
    61  func UpdateCommand() cli.Command {
    62  	return cli.Command{
    63  		Name:  "update",
    64  		Usage: "Download and install the version of gödel specified in the godel.properties file",
    65  		Action: func(ctx cli.Context) error {
    66  			return Update(cmd.WrapperFlagValue(ctx), ctx.App.Stdout)
    67  		},
    68  	}
    69  }