| 97 | } |
| 98 | |
| 99 | func commands(version func(c *cli.Context)) []*cli.Command { |
| 100 | cmds := []*cli.Command{ |
| 101 | { |
| 102 | Name: "update", |
| 103 | Action: cliutil.ConfiguredAction(updater.Update), |
| 104 | Usage: "Update the agent if a new version exists", |
| 105 | Flags: []cli.Flag{ |
| 106 | &cli.BoolFlag{ |
| 107 | Name: "beta", |
| 108 | Usage: "specify if you wish to update to the latest beta version", |
| 109 | }, |
| 110 | &cli.BoolFlag{ |
| 111 | Name: cfdflags.Force, |
| 112 | Usage: "specify if you wish to force an upgrade to the latest version regardless of the current version", |
| 113 | Hidden: true, |
| 114 | }, |
| 115 | &cli.BoolFlag{ |
| 116 | Name: "staging", |
| 117 | Usage: "specify if you wish to use the staging url for updating", |
| 118 | Hidden: true, |
| 119 | }, |
| 120 | &cli.StringFlag{ |
| 121 | Name: "version", |
| 122 | Usage: "specify a version you wish to upgrade or downgrade to", |
| 123 | Hidden: false, |
| 124 | }, |
| 125 | }, |
| 126 | Description: `Looks for a new version on the official download server. |
| 127 | If a new version exists, updates the agent binary and quits. |
| 128 | Otherwise, does nothing. |
| 129 | |
| 130 | To determine if an update happened in a script, check for error code 11.`, |
| 131 | }, |
| 132 | { |
| 133 | Name: "version", |
| 134 | Action: func(c *cli.Context) (err error) { |
| 135 | if c.Bool("short") { |
| 136 | fmt.Println(strings.Split(c.App.Version, " ")[0]) |
| 137 | return nil |
| 138 | } |
| 139 | version(c) |
| 140 | return nil |
| 141 | }, |
| 142 | Usage: versionText, |
| 143 | Description: versionText, |
| 144 | Flags: []cli.Flag{ |
| 145 | &cli.BoolFlag{ |
| 146 | Name: "short", |
| 147 | Aliases: []string{"s"}, |
| 148 | Usage: "print just the version number", |
| 149 | }, |
| 150 | }, |
| 151 | }, |
| 152 | } |
| 153 | cmds = append(cmds, tunnel.Commands()...) |
| 154 | cmds = append(cmds, proxydns.Command()) // removed feature, only here for error message |
| 155 | cmds = append(cmds, access.Commands()...) |
| 156 | cmds = append(cmds, tail.Command()) |