mirror of
https://codeberg.org/scip/esctl.git
synced 2026-08-24 14:44:18 +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{}
|
ops := []*Op{}
|
||||||
op := &Op{}
|
op := &Op{}
|
||||||
|
|
||||||
if verb == "" {
|
|
||||||
verb = "get"
|
|
||||||
}
|
|
||||||
|
|
||||||
for path, item := range assets.OpenAPI.Spec().Paths.Paths {
|
for path, item := range assets.OpenAPI.Spec().Paths.Paths {
|
||||||
if path == showpath {
|
if path == showpath {
|
||||||
ops = findOperation(item.PathItemProps)
|
ops = findOperation(item.PathItemProps)
|
||||||
@@ -468,6 +464,10 @@ func matchOperation(showpath, verb string) (*Op, error) {
|
|||||||
return nil, errors.New("no matching API call found")
|
return nil, errors.New("no matching API call found")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(ops) == 1 && verb == "" {
|
||||||
|
return ops[0], nil
|
||||||
|
}
|
||||||
|
|
||||||
for _, item := range ops {
|
for _, item := range ops {
|
||||||
if strings.ToLower(item.Verb) == verb {
|
if strings.ToLower(item.Verb) == verb {
|
||||||
op = item
|
op = item
|
||||||
@@ -509,14 +509,11 @@ func findOperation(item spec.PathItemProps) []*Op {
|
|||||||
|
|
||||||
func getTermWidth() int {
|
func getTermWidth() int {
|
||||||
if term.IsTerminal(int(os.Stdout.Fd())) {
|
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()))
|
width, _, err := term.GetSize(int(os.Stdout.Fd()))
|
||||||
if err != nil {
|
if err == nil {
|
||||||
return 80
|
return width - DefaultMargin
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return width - DefaultMargin
|
return 80
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user