fix panic and width determination

This commit is contained in:
2026-06-17 14:16:26 +02:00
parent 49bc2c7acb
commit 2f029304f3

View File

@@ -453,10 +453,6 @@ func matchOperation(showpath, verb string) (*Op, error) {
ops := []*Op{}
op := &Op{}
if verb == "" {
verb = "get"
}
for path, item := range assets.OpenAPI.Spec().Paths.Paths {
if path == showpath {
ops = findOperation(item.PathItemProps)
@@ -468,6 +464,10 @@ func matchOperation(showpath, verb string) (*Op, error) {
return nil, errors.New("no matching API call found")
}
if len(ops) == 1 && verb == "" {
return ops[0], nil
}
for _, item := range ops {
if strings.ToLower(item.Verb) == verb {
op = item
@@ -509,14 +509,11 @@ func findOperation(item spec.PathItemProps) []*Op {
func getTermWidth() int {
if term.IsTerminal(int(os.Stdout.Fd())) {
println("in a term")
} else {
println("not in a term")
}
width, _, err := term.GetSize(int(os.Stdout.Fd()))
if err != nil {
return 80
}
if err == nil {
return width - DefaultMargin
}
}
return 80
}