(inv *serpent.Invocation)
| 389 | } |
| 390 | |
| 391 | func (pf *templateUploadFlags) templateName(inv *serpent.Invocation) (string, error) { |
| 392 | args := inv.Args |
| 393 | if pf.stdin(inv) { |
| 394 | // Can't infer name from directory if none provided. |
| 395 | if len(args) == 0 { |
| 396 | return "", xerrors.New("template name argument must be provided") |
| 397 | } |
| 398 | return args[0], nil |
| 399 | } |
| 400 | |
| 401 | if len(args) > 0 { |
| 402 | return args[0], nil |
| 403 | } |
| 404 | // Have to take absPath to resolve "." and "..". |
| 405 | absPath, err := filepath.Abs(pf.directory) |
| 406 | if err != nil { |
| 407 | return "", err |
| 408 | } |
| 409 | // If no name is provided, use the directory name. |
| 410 | return filepath.Base(absPath), nil |
| 411 | } |
| 412 | |
| 413 | type createValidTemplateVersionArgs struct { |
| 414 | Name string |
no test coverage detected