We should get someone from Purdue to do this. They are the boilerplaters.

This commit is contained in:
2025-05-12 22:58:55 -04:00
parent 48d7730a5c
commit 9dbd7ecab8
11 changed files with 393 additions and 103 deletions

View File

@@ -0,0 +1,51 @@
package params
import (
"github.com/charmbracelet/huh"
)
type Enlarge struct {
enlarge *[]string
field huh.Field
}
func NewEnlarge() *Enlarge {
e := &Enlarge{
enlarge: &[]string{},
field: huh.NewMultiSelect[string]().
Options(
huh.NewOption("true", "true"),
).
Description("Whether to enlarge the image.").
WithKeyMap(
huh.NewDefaultKeyMap(),
),
}
e.enlarge = &[]string{}
e.field.(*huh.MultiSelect[string]).Value(e.enlarge)
return e
}
func (e Enlarge) Display() string {
return "enlarge"
}
func (e Enlarge) Value() string {
value := "0"
if len(*e.enlarge) > 0 {
value = "1"
}
return value
}
func (e Enlarge) Key() string {
return "el"
}
func (e Enlarge) Input() []huh.Field {
return []huh.Field{e.field}
}

View File

@@ -0,0 +1,41 @@
package params
import (
"github.com/aws/aws-sdk-go/aws"
"github.com/charmbracelet/huh"
)
type Height struct {
paramValue *string
field *huh.Input
}
func NewHeight() *Height {
h := &Height{
paramValue: aws.String(""),
field: huh.NewInput().
Key("h").
Description("The height of the image.").
Title("Height"),
}
h.field.Value(h.paramValue)
return h
}
func (h Height) Display() string {
return "height"
}
func (h Height) Value() string {
return *h.paramValue
}
func (h Height) Key() string {
return "h"
}
func (h Height) Input() []huh.Field {
return []huh.Field{h.field}
}

View File

@@ -0,0 +1,42 @@
package params
import (
"github.com/aws/aws-sdk-go/aws"
"github.com/charmbracelet/huh"
)
type MinHeight struct {
paramValue *string
field *huh.Input
}
func NewMinHeight() *MinHeight {
mh := &MinHeight{
paramValue: nil,
field: huh.NewInput().
Key("min-height").
Description("The minimum height of the image.").
Title("Min Height"),
}
mh.paramValue = aws.String("")
mh.field.Value(mh.paramValue)
return mh
}
func (mh MinHeight) Display() string {
return "min-height"
}
func (mh MinHeight) Value() string {
return *mh.paramValue
}
func (mh MinHeight) Key() string {
return "mh"
}
func (mh MinHeight) Input() []huh.Field {
return []huh.Field{mh.field}
}

View File

@@ -0,0 +1,42 @@
package params
import (
"github.com/aws/aws-sdk-go/aws"
"github.com/charmbracelet/huh"
)
type MinWidth struct {
paramValue *string
field *huh.Input
}
func NewMinWidth() *MinWidth {
mw := &MinWidth{
paramValue: nil,
field: huh.NewInput().
Key("min-width").
Description("The minimum width of the image.").
Title("Min Width"),
}
mw.paramValue = aws.String("")
mw.field.Value(mw.paramValue)
return mw
}
func (mw MinWidth) Display() string {
return "min-width"
}
func (mw MinWidth) Value() string {
return *mw.paramValue
}
func (mw MinWidth) Key() string {
return "mw"
}
func (mw MinWidth) Input() []huh.Field {
return []huh.Field{mw.field}
}

View File

@@ -0,0 +1,99 @@
package params
import (
"github.com/aws/aws-sdk-go/aws"
"github.com/charmbracelet/huh"
)
type Resize struct {
fields []huh.Field
height *string
width *string
resizeType *string
enlarge *[]string
extent *[]string
}
func NewResize() *Resize {
rs := &Resize{
fields: []huh.Field{
huh.NewInput().
Key("resize.height").
Description("The height of the image.").
Title("Height"),
huh.NewInput().
Key("resize.width").
Description("The width of the image.").
Title("Width"),
huh.NewSelect[string]().
Title("Resize Type").
Options(
huh.NewOption("fit", "fit"),
huh.NewOption("fill", "fill"),
huh.NewOption("fill-down", "fill-down"),
huh.NewOption("force", "force"),
huh.NewOption("auto", "auto"),
).WithKeyMap(huh.NewDefaultKeyMap()),
huh.NewMultiSelect[string]().
Options(
huh.NewOption("true", "true"),
).
Description("Whether to enlarge the image.").
WithKeyMap(
huh.NewDefaultKeyMap(),
),
huh.NewMultiSelect[string]().
Options(
huh.NewOption("true", "true"),
).
Description("Whether to extend the image.").
WithKeyMap(
huh.NewDefaultKeyMap(),
),
},
}
rs.height = aws.String("")
rs.width = aws.String("")
rs.enlarge = &[]string{}
rs.extent = &[]string{}
rs.resizeType = aws.String("auto")
rs.fields[0].(*huh.Input).Value(rs.height)
rs.fields[1].(*huh.Input).Value(rs.width)
rs.fields[2].(*huh.Select[string]).Value(rs.resizeType)
rs.fields[3].(*huh.MultiSelect[string]).Value(rs.enlarge)
rs.fields[4].(*huh.MultiSelect[string]).Value(rs.extent)
return rs
}
func (r Resize) Display() string {
return "resize"
}
func (r Resize) Value() string {
if *r.height == "" || *r.width == "" {
return ""
}
resize := "0"
if *r.enlarge != nil && len(*r.enlarge) > 0 {
resize = "1"
}
extent := "0"
if *r.extent != nil && len(*r.extent) > 0 {
extent = "1"
}
return *r.resizeType + ":" + *r.height + ":" + *r.width + ":" + resize + ":" + extent
}
func (r Resize) Key() string {
return "rs"
}
func (r Resize) Input() []huh.Field {
return r.fields
}

View File

@@ -0,0 +1,41 @@
package params
import (
"github.com/aws/aws-sdk-go/aws"
"github.com/charmbracelet/huh"
)
type Width struct {
paramValue *string
field *huh.Input
}
func NewWidth() *Width {
w := &Width{
paramValue: aws.String(""),
field: huh.NewInput().
Key("h").
Description("The width of the image.").
Title("Width"),
}
w.field.Value(w.paramValue)
return w
}
func (h Width) Display() string {
return "width"
}
func (h Width) Value() string {
return *h.paramValue
}
func (h Width) Key() string {
return "h"
}
func (h Width) Input() []huh.Field {
return []huh.Field{h.field}
}

View File

@@ -0,0 +1,41 @@
package params
import (
"github.com/aws/aws-sdk-go/aws"
"github.com/charmbracelet/huh"
)
type Zoom struct {
zoom *string
field huh.Field
}
func NewZoom() *Zoom {
z := &Zoom{
zoom: aws.String(""),
field: huh.NewInput().
Key("z").
Description("Percentage to zoom the image (1.4 == 140%) .").
Title("Zoom"),
}
z.field.(*huh.Input).Value(z.zoom)
return z
}
func (z *Zoom) Value() string {
return *z.zoom
}
func (z *Zoom) Display() string {
return "zoom"
}
func (z *Zoom) Key() string {
return "z"
}
func (z *Zoom) Input() []huh.Field {
return []huh.Field{z.field}
}