input_autocomplete

package module
v0.0.0-...-86159f8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 5, 2026 License: MIT Imports: 7 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

go-input-autocomplete

A useful input that can autocomplete users path to directories or files when tab key is pressed. The purpose is to be similar to bash/cmd native autocompletion.

Installation

go get github.com/JoaoDanielRufino/go-input-autocomplete

Usage

package main

import (
	"fmt"
	input_autocomplete "github.com/JoaoDanielRufino/go-input-autocomplete"
)

func main() {
	path, err := input_autocomplete.Read("Path: ")

	if err != nil {
		panic(err)
	}

	fmt.Println(path)
}

How it works

gif

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Autocomplete

func Autocomplete(path string) []string

func EnableVirtualTerminalWindows

func EnableVirtualTerminalWindows() error

func Read

func Read(text string) (string, error)

Types

type Cmd

type Cmd struct{}

func (Cmd) IsDir

func (c Cmd) IsDir(path string) (bool, error)

func (Cmd) ListContent

func (c Cmd) ListContent(path string) ([]string, error)

type Cursor

type Cursor struct {
	// contains filtered or unexported fields
}

func NewCursor

func NewCursor() *Cursor

func (*Cursor) GetPosition

func (c *Cursor) GetPosition() int

func (*Cursor) IncrementPosition

func (c *Cursor) IncrementPosition()

func (*Cursor) MoveLeft

func (c *Cursor) MoveLeft()

func (*Cursor) MoveLeftNPos

func (c *Cursor) MoveLeftNPos(x int)

func (*Cursor) MoveRight

func (c *Cursor) MoveRight()

func (*Cursor) SetPosition

func (c *Cursor) SetPosition(newPos int)

type DirChecker

type DirChecker interface {
	IsDir(path string) (bool, error)
}

type DirListChecker

type DirListChecker interface {
	DirLister
	DirChecker
}

type DirLister

type DirLister interface {
	ListContent(path string) ([]string, error)
}

type Input

type Input struct {
	// contains filtered or unexported fields
}

func NewInput

func NewInput(fixedText string) *Input

func (*Input) AddChar

func (i *Input) AddChar(char rune)

func (*Input) Autocomplete

func (i *Input) Autocomplete()

func (*Input) GetCurrentText

func (i *Input) GetCurrentText() string

func (*Input) MoveCursorLeft

func (i *Input) MoveCursorLeft()

func (*Input) MoveCursorRight

func (i *Input) MoveCursorRight()

func (*Input) Print

func (i *Input) Print()

func (*Input) PrintAllMatches

func (i *Input) PrintAllMatches()

func (*Input) RemoveChar

func (i *Input) RemoveChar()

func (*Input) RemoveLastSlashIfNeeded

func (i *Input) RemoveLastSlashIfNeeded()

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址