Skip to content

Commit

Permalink
Move shortcut options from oviewer to main
Browse files Browse the repository at this point in the history
Transferred shortcut handling for align and raw
from oviewer/oviewer.go to main.go.
  • Loading branch information
noborus committed Sep 14, 2024
1 parent 95f5dd8 commit 9d98adf
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
16 changes: 14 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ var (
completion string
// execCommand targets the output of executing the command.
execCommand bool

// alignF is align column.
alignF bool
// rawF is raw output of escape sequences.
rawF bool
)

var (
Expand Down Expand Up @@ -99,6 +104,13 @@ It supports various compressed files(gzip, bzip2, zstd, lz4, and xz).
config.General.SectionHeader = true
}

// Set a converter by specifying flag.
if alignF {
config.General.Converter = "align"
} else if rawF {
config.General.Converter = "raw"
}

// Set a global variable to convert to a style before opening the file.
oviewer.OverStrikeStyle = oviewer.ToTcellStyle(config.StyleOverStrike)
oviewer.OverLineStyle = oviewer.ToTcellStyle(config.StyleOverLine)
Expand Down Expand Up @@ -358,8 +370,8 @@ func init() {
rootCmd.PersistentFlags().StringVarP(&nonMatchFilter, "non-match-filter", "", "", "filter non match search pattern")
rootCmd.PersistentFlags().BoolVarP(&oviewer.SkipExtract, "skip-extract", "", false, "skip extracting compressed files")

rootCmd.PersistentFlags().BoolVarP(&oviewer.AlignF, "align", "", false, "align column")
rootCmd.PersistentFlags().BoolVarP(&oviewer.RawF, "raw", "", false, "raw output of escape sequences")
rootCmd.PersistentFlags().BoolVarP(&alignF, "align", "l", false, "align column")
rootCmd.PersistentFlags().BoolVarP(&rawF, "raw", "r", false, "raw output of escape sequences")

// Config.General
rootCmd.PersistentFlags().StringP("converter", "", "es", "converter [es|raw|align]")
Expand Down
13 changes: 0 additions & 13 deletions oviewer/oviewer.go
Original file line number Diff line number Diff line change
Expand Up @@ -373,12 +373,6 @@ const (

var Shrink rune = '…'

// RawF is specifies converter shortcut for raw.
var RawF bool

// AlignF is specifies converter shortcut for align.
var AlignF bool

var (
// ErrOutOfRange indicates that value is out of range.
ErrOutOfRange = errors.New("out of range")
Expand Down Expand Up @@ -706,13 +700,6 @@ func (root *Root) prepareRun(ctx context.Context) error {
root.Screen.EnableMouse(MouseFlags)
}

if RawF {
root.General.Converter = convRaw
}
if AlignF {
root.General.Converter = convAlign
}

if root.Config.ShrinkChar != "" {
Shrink = []rune(root.Config.ShrinkChar)[0]
}
Expand Down

0 comments on commit 9d98adf

Please sign in to comment.