| 20 | } |
| 21 | |
| 22 | func functionName(args []string) string { |
| 23 | if len(args) == 0 { |
| 24 | return "" |
| 25 | } |
| 26 | |
| 27 | for _, arg := range args { |
| 28 | if strings.HasPrefix(arg, "-") { |
| 29 | if !strings.Contains(arg, "=") { |
| 30 | // this flag is not self-contained so we can't be sure what the |
| 31 | // top level function is |
| 32 | return "" |
| 33 | } |
| 34 | // it is a self contained flag os we are fine to continue scanning |
| 35 | continue |
| 36 | } |
| 37 | |
| 38 | // we have the first non-flag argument which should be the top level function |
| 39 | // name so we return it |
| 40 | return arg |
| 41 | } |
| 42 | |
| 43 | // weird case that would happen when users make a dagger call with no functions |
| 44 | // an edge-case but we cover it anyway |
| 45 | return "" |
| 46 | } |