mirror of
https://codeberg.org/scip/esctl.git
synced 2026-08-24 08:04:17 +02:00
fix panic and width determination
This commit is contained in:
@@ -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
|
||||
width, _, err := term.GetSize(int(os.Stdout.Fd()))
|
||||
if err == nil {
|
||||
return width - DefaultMargin
|
||||
}
|
||||
}
|
||||
|
||||
return width - DefaultMargin
|
||||
return 80
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user