Introduction to the Infinite Project
The Infinite project is designed to enhance the development of interactive command-line applications using the Go programming language. This library provides a collection of useful components that developers can easily integrate into their applications to create a more engaging user experience.
Features of Infinite
Infinite includes several features aimed at improving the interaction within command-line applications:
- Multi/Single Select: This feature allows developers to implement both multi-select and single-select options, enabling users to choose multiple items from a list or just a single item, respectively.
- Progress-Bar Group: Developers can create progress bars that inform users about the progress of a task, making it easier to track the completion of tasks within the application.
- Spinner: Spinners give users visual feedback that a process is ongoing, which can be helpful during operations that take time to complete.
- Confirm (Input/Selection): With confirm dialogs, users can validate their actions by confirming inputs or selections before proceeding, ensuring that the user is making intentional choices.
- Input: This feature simplifies capturing user input directly from the command line, tailoring the application to take actions based on user data entry.
Installation
To start using Infinite in your Go projects, simply run the following command in your terminal:
go get github.com/fzdwx/infinite@main
This command will download the Infinite library from the specified GitHub repository, allowing you to include it in your applications.
Example Usage
Consider the following example that illustrates how Infinite can be used to implement a simple multi-select feature in a Go application:
func main() {
input := components.NewInput()
input.Prompt = "Filtering: "
input.PromptStyle = style.New().Bold().Italic().Fg(color.LightBlue)
keymap := components.DefaultMultiKeyMap()
keymap.Choice = key.NewBinding(
key.WithKeys(tea.KeySpace.String()),
)
_, _ = inf.NewMultiSelect([]string{
"a", "b", "c",
"d", "e",
"f",
"g",
"h",
},
multiselect.WithKeyMap(keymap),
multiselect.WithHintSymbol("x"),
multiselect.WithUnHintSymbol("√"),
multiselect.WithPageSize(3),
multiselect.WithFilterInput(input),
).
Display("select your items!")
}
This code snippet demonstrates how to set up a multi-select component where users can filter through their options and select items. The example utilizes a custom key mapping for navigation and the ability to display only a subset of items at a time using pagination.
For more detailed examples and usage guides, you can explore Infinite's GitHub page: Infinite Examples.
Licensing
The Infinite project is licensed under the MIT License, making it a flexible choice for both open-source and proprietary software development. This allows developers to freely use, modify, and distribute the library within their own applications.
By integrating Infinite into their command-line projects, developers can significantly enhance user interaction and interface responsiveness, delivering a more intuitive and effective user experience.