Documentation
¶
Overview ¶
Copyright © 2025 Daniel Rivas <danielrivasmd@gmail.com>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
Copyright © 2025 Daniel Rivas <danielrivasmd@gmail.com>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
Copyright © 2025 Daniel Rivas <danielrivasmd@gmail.com>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
Copyright © 2025 Daniel Rivas <danielrivasmd@gmail.com>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
Copyright © 2025 Daniel Rivas <danielrivasmd@gmail.com>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
Copyright © 2025 Daniel Rivas <danielrivasmd@gmail.com>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
Copyright © 2025 Daniel Rivas <danielrivasmd@gmail.com>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
Copyright © 2025 Daniel Rivas <danielrivasmd@gmail.com>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
Copyright © 2025 Daniel Rivas <danielrivasmd@gmail.com>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
Copyright © 2025 Daniel Rivas <danielrivasmd@gmail.com>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
Copyright © 2025 Daniel Rivas <danielrivasmd@gmail.com>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
Copyright © 2025 Daniel Rivas <danielrivasmd@gmail.com>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
Index ¶
- Constants
- func Assign(field string, holder any, v any)
- func AssignBool(field string, holder any, v any)
- func AssignDate(field string, holder any, v any)
- func AssignInt64(field string, holder any, v any)
- func AssignNullableDate(field string, holder any, v any)
- func AssignString(field string, holder any, v any)
- func AttachEditCompletion[T any](cmd *cobra.Command, listFn func(ctx context.Context, db *sql.DB) ([]T, error), ...)
- func AttachRmCompletion[T any](cmd *cobra.Command, listFn func(ctx context.Context, db *sql.DB) ([]T, error), ...)
- func EnsureDB() error
- func Execute()
- func OptInt64Initial(v null.Int64) string
- func OptStringInitial(v null.String) string
- func OptTimeInitial(v null.Time, layout string) string
- func ParseBool(s string) (any, error)
- func ParseDate(s string) (any, error)
- func ParseInt64(s string) (any, error)
- func ParseNonEmpty(label string) func(string) (any, error)
- func ParseOptDate(s string) (any, error)
- func ParseOptInt64(s string) (any, error)
- func ParseOptString(s string) (any, error)
- func RegisterCrudSubcommands[T any](parent *cobra.Command, dbPath string, desc CrudModel[T])
- func RenderTable(headers []string, rows [][]string) string
- func RunFormWizard(fields []Field, holder any)
- func RunFormWizardWithSubmit(fields []Field, holder any, onSubmit func(holder any) error)
- func VBool(label string) func(string) error
- func VDate(label string) func(string) error
- func VDateOptional() func(string) error
- func VIntRange(min, max int64) func(string) error
- func VRequired(label string) func(string) error
- type CrudModel
- type Field
- func FBool(label, field, initial string) Field
- func FChoice(label string, initial string, allow []string, setter func(string)) Field
- func FDate(label, field, initial string, opts ...FieldOpt) Field
- func FInt(label, field, initial string, opts ...FieldOpt) Field
- func FOptDate(label, field, initial string, opts ...FieldOpt) Field
- func FOptInt(label, field, initial string, opts ...FieldOpt) Field
- func FOptString(label, field, initial string, opts ...FieldOpt) Field
- func FString(label, field, initial string, opts ...FieldOpt) Field
- type FieldOpt
- type FormModel
Constants ¶
const DateYMD = "2006-01-02"
date format
Variables ¶
This section is empty.
Functions ¶
func Assign ¶
Assign sets any null.* wrapper (null.String, null.Int64, null.Bool, null.Time) into a named field.
func AssignBool ¶
AssignBool sets a bool into a named field.
func AssignDate ¶
AssignDate sets a time.Time into a named field (for NOT NULL date/time columns).
func AssignInt64 ¶
AssignInt64 sets an int64 into a named field (e.g., FK task).
func AssignNullableDate ¶
AssignNullableDate sets a null.Time into a named field (for nullable dates).
func AssignString ¶
AssignString sets a plain string into a named field.
func AttachEditCompletion ¶
func AttachRmCompletion ¶
func EnsureDB ¶
func EnsureDB() error
TODO: needed ensuredb? EnsureDB open the DB using the same logic as dbPreRun reuse that here so __complete has a live connection
func OptInt64Initial ¶
func OptStringInitial ¶
func ParseNonEmpty ¶
ParseNonEmpty returns the string if non-empty; else error.
func ParseOptDate ¶
ParseOptDate parses an optional date (YYYY-MM-DD) into null.Time.
func ParseOptInt64 ¶
ParseOptInt64 parses an optional int64 into null.Int64.
func ParseOptString ¶
ParseOptString converts free text into null.String (blank → Valid:true, String:"").
func RegisterCrudSubcommands ¶
func RenderTable ¶
func RunFormWizard ¶
func RunFormWizardWithSubmit ¶
func VDateOptional ¶
VDateOptional validates optional YYYY-MM-DD date (for null.Time).
Types ¶
type CrudModel ¶
type CrudModel[T any] struct { Singular string ListFn func(ctx context.Context, db *sql.DB) ([]T, error) RemoveFn func(ctx context.Context, db *sql.DB, id int64) error Format func(item T) (int64, string) TableHeaders []string TableRow func(item T) []string HintFn func(item T) string }
TODO: add verbose option
type Field ¶
type Field struct {
Name string
Label string
Initial string
Validate func(input string) error
Parse func(string) (any, error)
Assign func(holder any, v any)
Input textinput.Model
// contains filtered or unexported fields
}
func FBool ¶
FBool builds a boolean field (plain bool). If your model uses null.Bool, wrap with null.BoolFrom in Assign.
func FOptString ¶
FOptString remains optional; add opts for consistency.
type FormModel ¶
type FormModel struct {
// contains filtered or unexported fields
}