mirror of
https://github.com/jesseduffield/lazygit.git
synced 2024-12-02 09:21:40 +02:00
rename OSCommand field to os
This commit is contained in:
parent
d82f175e79
commit
cd31a762b9
@ -72,9 +72,14 @@ func FileType(path string) string {
|
||||
}
|
||||
|
||||
func (c *OSCommand) OpenFile(filename string) error {
|
||||
return c.OpenFileAtLine(filename, 1)
|
||||
}
|
||||
|
||||
func (c *OSCommand) OpenFileAtLine(filename string, lineNumber int) error {
|
||||
commandTemplate := c.UserConfig.OS.OpenCommand
|
||||
templateValues := map[string]string{
|
||||
"filename": c.Quote(filename),
|
||||
"line": fmt.Sprintf("%d", lineNumber),
|
||||
}
|
||||
command := utils.ResolvePlaceholderString(commandTemplate, templateValues)
|
||||
return c.Cmd.NewShell(command).Run()
|
||||
|
@ -79,7 +79,7 @@ func (gui *Gui) handleCopyPullRequestURLPress() error {
|
||||
return gui.c.Error(err)
|
||||
}
|
||||
gui.c.LogAction(gui.c.Tr.Actions.CopyPullRequestURL)
|
||||
if err := gui.OSCommand.CopyToClipboard(url); err != nil {
|
||||
if err := gui.os.CopyToClipboard(url); err != nil {
|
||||
return gui.c.Error(err)
|
||||
}
|
||||
|
||||
|
@ -10,6 +10,7 @@ type IFilesHelper interface {
|
||||
EditFile(filename string) error
|
||||
EditFileAtLine(filename string, lineNumber int) error
|
||||
OpenFile(filename string) error
|
||||
OpenFileAtLine(filename string, lineNumber int) error
|
||||
}
|
||||
|
||||
type FilesHelper struct {
|
||||
@ -49,8 +50,12 @@ func (self *FilesHelper) EditFileAtLine(filename string, lineNumber int) error {
|
||||
}
|
||||
|
||||
func (self *FilesHelper) OpenFile(filename string) error {
|
||||
return self.OpenFileAtLine(filename, 1)
|
||||
}
|
||||
|
||||
func (self *FilesHelper) OpenFileAtLine(filename string, lineNumber int) error {
|
||||
self.c.LogAction(self.c.Tr.Actions.OpenFile)
|
||||
if err := self.os.OpenFile(filename); err != nil {
|
||||
if err := self.os.OpenFileAtLine(filename, lineNumber); err != nil {
|
||||
return self.c.Error(err)
|
||||
}
|
||||
return nil
|
||||
|
@ -247,7 +247,7 @@ func (gui *Gui) handleCustomCommandKeybinding(customCommand config.CustomCommand
|
||||
}
|
||||
|
||||
if customCommand.Subprocess {
|
||||
return gui.runSubprocessWithSuspenseAndRefresh(gui.OSCommand.Cmd.NewShell(cmdStr))
|
||||
return gui.runSubprocessWithSuspenseAndRefresh(gui.os.Cmd.NewShell(cmdStr))
|
||||
}
|
||||
|
||||
loadingText := customCommand.LoadingText
|
||||
@ -256,7 +256,7 @@ func (gui *Gui) handleCustomCommandKeybinding(customCommand config.CustomCommand
|
||||
}
|
||||
return gui.c.WithWaitingStatus(loadingText, func() error {
|
||||
gui.c.LogAction(gui.c.Tr.Actions.CustomCommand)
|
||||
cmdObj := gui.OSCommand.Cmd.NewShell(cmdStr)
|
||||
cmdObj := gui.os.Cmd.NewShell(cmdStr)
|
||||
if customCommand.Stream {
|
||||
cmdObj.StreamOutput()
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ func (gui *Gui) exitDiffMode() error {
|
||||
}
|
||||
|
||||
func (gui *Gui) renderDiff() error {
|
||||
cmdObj := gui.OSCommand.Cmd.New(
|
||||
cmdObj := gui.os.Cmd.New(
|
||||
fmt.Sprintf("git diff --submodule --no-ext-diff --color %s", gui.diffStr()),
|
||||
)
|
||||
task := NewRunPtyTask(cmdObj.GetCmd())
|
||||
|
@ -219,7 +219,7 @@ func (gui *Gui) handleCopySelectedSideContextItemToClipboard() error {
|
||||
}
|
||||
|
||||
gui.c.LogAction(gui.c.Tr.Actions.CopyToClipboard)
|
||||
if err := gui.OSCommand.CopyToClipboard(itemId); err != nil {
|
||||
if err := gui.os.CopyToClipboard(itemId); err != nil {
|
||||
return gui.c.Error(err)
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,7 @@ func (gui *Gui) withGpgHandling(cmdObj oscommands.ICmdObj, waitingStatus string,
|
||||
|
||||
useSubprocess := gui.git.Config.UsingGpg()
|
||||
if useSubprocess {
|
||||
success, err := gui.runSubprocessWithSuspense(gui.OSCommand.Cmd.NewShell(cmdObj.ToString()))
|
||||
success, err := gui.runSubprocessWithSuspense(gui.os.Cmd.NewShell(cmdObj.ToString()))
|
||||
if success && onSuccess != nil {
|
||||
if err := onSuccess(); err != nil {
|
||||
return err
|
||||
@ -36,7 +36,7 @@ func (gui *Gui) withGpgHandling(cmdObj oscommands.ICmdObj, waitingStatus string,
|
||||
|
||||
func (gui *Gui) RunAndStream(cmdObj oscommands.ICmdObj, waitingStatus string, onSuccess func() error) error {
|
||||
return gui.c.WithWaitingStatus(waitingStatus, func() error {
|
||||
cmdObj := gui.OSCommand.Cmd.NewShell(cmdObj.ToString())
|
||||
cmdObj := gui.os.Cmd.NewShell(cmdObj.ToString())
|
||||
cmdObj.AddEnvVars("TERM=dumb")
|
||||
cmdWriter := gui.getCmdWriter()
|
||||
cmd := cmdObj.GetCmd()
|
||||
|
@ -83,9 +83,9 @@ type Repo string
|
||||
// Gui wraps the gocui Gui object which handles rendering and events
|
||||
type Gui struct {
|
||||
*common.Common
|
||||
g *gocui.Gui
|
||||
git *commands.GitCommand
|
||||
OSCommand *oscommands.OSCommand
|
||||
g *gocui.Gui
|
||||
git *commands.GitCommand
|
||||
os *oscommands.OSCommand
|
||||
|
||||
// this is the state of the GUI for the current repo
|
||||
State *GuiRepoState
|
||||
@ -318,7 +318,7 @@ func (gui *Gui) onNewRepo(filterPath string, reuseState bool) error {
|
||||
var err error
|
||||
gui.git, err = commands.NewGitCommand(
|
||||
gui.Common,
|
||||
gui.OSCommand,
|
||||
gui.os,
|
||||
git_config.NewStdCachedGitConfig(gui.Log),
|
||||
gui.Mutexes.SyncMutex,
|
||||
)
|
||||
@ -479,7 +479,7 @@ func NewGui(
|
||||
|
||||
osCommand := oscommands.NewOSCommand(cmn, oscommands.GetPlatform(), guiIO)
|
||||
|
||||
gui.OSCommand = osCommand
|
||||
gui.os = osCommand
|
||||
|
||||
gui.watchFilesForChanges()
|
||||
|
||||
@ -509,7 +509,7 @@ func NewGui(
|
||||
|
||||
func (gui *Gui) resetControllers() {
|
||||
controllerCommon := gui.c
|
||||
osCommand := gui.OSCommand
|
||||
osCommand := gui.os
|
||||
rebaseHelper := controllers.NewRebaseHelper(controllerCommon, gui.State.Contexts, gui.git, gui.takeOverMergeConflictScrolling)
|
||||
model := gui.State.Model
|
||||
gui.helpers = &Helpers{
|
||||
@ -977,7 +977,7 @@ func (gui *Gui) loadNewRepo() error {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := gui.OSCommand.UpdateWindowTitle(); err != nil {
|
||||
if err := gui.os.UpdateWindowTitle(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -44,9 +44,9 @@ func (gui *Gui) handleInfoClick() error {
|
||||
|
||||
// if we're not in an active mode we show the donate button
|
||||
if cx <= len(gui.c.Tr.Donate) {
|
||||
return gui.OSCommand.OpenLink(constants.Links.Donate)
|
||||
return gui.os.OpenLink(constants.Links.Donate)
|
||||
} else if cx <= len(gui.c.Tr.Donate)+1+len(gui.c.Tr.AskQuestion) {
|
||||
return gui.OSCommand.OpenLink(constants.Links.Discussions)
|
||||
return gui.os.OpenLink(constants.Links.Discussions)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ func (gui *Gui) copySelectedToClipboard() error {
|
||||
selected := state.PlainRenderSelected()
|
||||
|
||||
gui.c.LogAction(gui.c.Tr.Actions.CopySelectedTextToClipboard)
|
||||
if err := gui.OSCommand.CopyToClipboard(selected); err != nil {
|
||||
if err := gui.os.CopyToClipboard(selected); err != nil {
|
||||
return gui.c.Error(err)
|
||||
}
|
||||
|
||||
@ -210,7 +210,7 @@ func (gui *Gui) handleOpenFileAtLine() error {
|
||||
|
||||
// need to look at current index, then work out what my hunk's header information is, and see how far my line is away from the hunk header
|
||||
lineNumber := state.CurrentLineNumber()
|
||||
if err := gui.editFileAtLine(filename, lineNumber); err != nil {
|
||||
if err := gui.os.OpenFileAtLine(filename, lineNumber); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -64,7 +64,7 @@ func (gui *Gui) createPullRequest(from string, to string) error {
|
||||
|
||||
gui.c.LogAction(gui.c.Tr.Actions.OpenPullRequest)
|
||||
|
||||
if err := gui.OSCommand.OpenLink(url); err != nil {
|
||||
if err := gui.os.OpenLink(url); err != nil {
|
||||
return gui.c.Error(err)
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,7 @@ func (gui *Gui) recordDirectory(dirName string) error {
|
||||
if newDirFilePath == "" {
|
||||
return nil
|
||||
}
|
||||
return gui.OSCommand.CreateFileWithContent(newDirFilePath, dirName)
|
||||
return gui.os.CreateFileWithContent(newDirFilePath, dirName)
|
||||
}
|
||||
|
||||
func (gui *Gui) handleQuitWithoutChangingDirectory() error {
|
||||
|
@ -62,7 +62,7 @@ func (gui *Gui) dispatchSwitchToRepo(path string, reuse bool) error {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := commands.VerifyInGitRepo(gui.OSCommand); err != nil {
|
||||
if err := commands.VerifyInGitRepo(gui.os); err != nil {
|
||||
if err := os.Chdir(originalPath); err != nil {
|
||||
return err
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user