cmd

package
v0.0.0-...-5633a3e Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2023 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Copyright © 2023 Jake Romer <jmromer@tensorconclave.com>

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright © 2023 Jake Romer <jmromer@tensorconclave.com>

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright © 2023 Jake Romer <jmromer@tensorconclave.com>

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ChangeDirectory

func ChangeDirectory(target string)

ChangeDirectory resolves the given path to an absolute path Logs an entry to the history log and refreshes the project listing

func Execute

func Execute()

Execute is called by main.main(). It only needs to happen once to the rootCmd.

func FzfPreview

func FzfPreview(label string)

FzfPreview triggers a preview (file listing) of the directory associated with the given project label.

List the files in the directory associated with the given project label. Used in the FZF preview window. Attempts to do this using exa, then tree if exa is unavailable or fails. Falls back to ls if both fail.

Examples: pd --fzf-preview my-project Documents/projects pd --fzf-preview my-other-project

func RefreshLog

func RefreshLog(searchForProjects bool)

RefreshLog finds all version-controlled projects $HOME and refresh the history. Refreshing the history removes any directories that no longer exist, and re-aggregates and re-ranks entries.

func SelectProject

func SelectProject()

Use FZF to select a project directory, printing to stdout the absolute path to the project directory.

Types

type ByCount

type ByCount []LogEntry

Sorting interfaces

func (ByCount) Len

func (a ByCount) Len() int

func (ByCount) Less

func (a ByCount) Less(i, j int) bool

func (ByCount) Swap

func (a ByCount) Swap(i, j int)

type ByName

type ByName []LogEntry

func (ByName) Len

func (a ByName) Len() int

func (ByName) Less

func (a ByName) Less(i, j int) bool

func (ByName) Swap

func (a ByName) Swap(i, j int)

type LogEntry

type LogEntry struct {
	Count   int
	AbsPath string
	Name    string
	Path    string
}

Each entry in the pd history file consists of a count, an abs path, and the colored project label to be used in the FZF interface.

func (LogEntry) Label

func (e LogEntry) Label() string

Project label, unformatted

func (LogEntry) LabelFormatted

func (e LogEntry) LabelFormatted() string

Project label, formatted (ansi-color)

func (LogEntry) LogLine

func (e LogEntry) LogLine() string

History entry format is CSV with `count`, `absolute path`, and `project label`

func (LogEntry) WriteLogLine

func (e LogEntry) WriteLogLine(file *os.File)

Write the given LogEntry to the given file handle.

Jump to

Keyboard shortcuts

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