| 178 | } |
| 179 | |
| 180 | func NewCmdUnlock(f *cmdutil.Factory, parentName string, runF func(string, *LockOptions) error) *cobra.Command { |
| 181 | opts := &LockOptions{ParentCmd: parentName} |
| 182 | |
| 183 | c := alias[opts.ParentCmd] |
| 184 | short := fmt.Sprintf("Unlock %s conversation", strings.ToLower(c.FullName)) |
| 185 | |
| 186 | cmd := &cobra.Command{ |
| 187 | Use: "unlock {<number> | <url>}", |
| 188 | Short: short, |
| 189 | Args: cobra.ExactArgs(1), |
| 190 | RunE: func(cmd *cobra.Command, args []string) error { |
| 191 | if err := opts.setCommonOptions(f, args); err != nil { |
| 192 | return err |
| 193 | } |
| 194 | |
| 195 | if runF != nil { |
| 196 | return runF(Unlock, opts) |
| 197 | } |
| 198 | return lockRun(Unlock, opts) |
| 199 | }, |
| 200 | } |
| 201 | |
| 202 | return cmd |
| 203 | } |
| 204 | |
| 205 | // reason creates a sentence fragment so that the lock reason can be used in a |
| 206 | // sentence. |