Remove automatic pager functionality
This commit is contained in:
parent
35a880ae26
commit
1c9bb056e8
4 changed files with 2 additions and 63 deletions
10
README.md
10
README.md
|
@ -20,11 +20,6 @@ A Psalm of David.
|
|||
He makes me lie down in green pastures....
|
||||
```
|
||||
|
||||
If the requested passage is over 32 lines long, `esv` will pipe it through
|
||||
a pager (default less). The pager being used can be changed through the
|
||||
`ESV_PAGER` environment variable or just disabled altogether by passing the
|
||||
-P option.
|
||||
|
||||
The names of Bible books are not case sensitive, so John, john, and JOHN
|
||||
are all accepted.
|
||||
|
||||
|
@ -63,11 +58,6 @@ $ make
|
|||
# make install
|
||||
```
|
||||
|
||||
<!--
|
||||
By default the configure script looks for ldc and dmd in your PATH
|
||||
and optimises the command-line arguments based on the compiler.
|
||||
-->
|
||||
|
||||
## Documentation
|
||||
|
||||
All documentation is contained in the manual pages. To access them, you can run
|
||||
|
|
|
@ -7,10 +7,8 @@ public:
|
|||
enum DEFAULT_APIKEY = "abfb7456fa52ec4292c79e435890cfa3df14dc2b";
|
||||
enum DEFAULT_CONFIGPATH = "~/.config/esv.conf";
|
||||
enum DEFAULT_MPEGPLAYER = "mpg123";
|
||||
enum DEFAULT_PAGER = "less";
|
||||
|
||||
enum ENV_CONFIG = "ESV_CONFIG";
|
||||
enum ENV_PAGER = "ESV_PAGER";
|
||||
enum ENV_PLAYER = "ESV_PLAYER";
|
||||
|
||||
enum BUGREPORTURL = "https://codeberg.org/jtbx/esv/issues";
|
||||
|
|
16
esv.1
16
esv.1
|
@ -24,14 +24,6 @@ to fast-forward, etc. Read about the
|
|||
.Fl C
|
||||
option in mpg123's manual for more information.
|
||||
.Pp
|
||||
If a text passage is too long for standard display on a terminal,
|
||||
.Nm
|
||||
will put it through a text pager (default less) in order for you to be able to
|
||||
scroll through the text. This behaviour can be disabled by passing
|
||||
the
|
||||
.Fl P
|
||||
flag.
|
||||
.Pp
|
||||
The options are as follows:
|
||||
.Bl -tag -width keyword
|
||||
.It Fl a
|
||||
|
@ -59,9 +51,6 @@ as the maximum line length.
|
|||
Exclude verse numbers.
|
||||
.It Fl n
|
||||
Include verse numbers (the default).
|
||||
.It Fl P
|
||||
If the passage is over 32 lines long, don't
|
||||
pipe it into a pager.
|
||||
.It Fl R
|
||||
Exclude passage references.
|
||||
.It Fl r
|
||||
|
@ -73,11 +62,6 @@ Print the version number and exit.
|
|||
.It Ev ESV_CONFIG
|
||||
Where to read the configuration file, rather than using the default location (see section
|
||||
.Sx FILES ) .
|
||||
.It Ev ESV_PAGER
|
||||
What pager to use when the passage is over 32 lines long, rather than using
|
||||
the
|
||||
.Ic less
|
||||
utility.
|
||||
.It Ev ESV_PLAYER
|
||||
What MP3 player to use for playing audio, rather than using mpg123.
|
||||
Using mpg123 is recommended over other players such as mpv, because
|
||||
|
|
37
esv.d
37
esv.d
|
@ -44,7 +44,6 @@ bool fFlag, FFlag; /* footnotes */
|
|||
bool hFlag, HFlag; /* headings */
|
||||
int lFlag; /* line length */
|
||||
bool nFlag, NFlag; /* verse numbers */
|
||||
bool PFlag; /* disable pager */
|
||||
bool rFlag, RFlag; /* passage references */
|
||||
string sFlag; /* search passages */
|
||||
bool VFlag; /* show version */
|
||||
|
@ -79,11 +78,8 @@ main(string[] args)
|
|||
bool
|
||||
run(string[] args)
|
||||
{
|
||||
ushort lines;
|
||||
string apiKey;
|
||||
string configPath;
|
||||
string pager;
|
||||
string verses;
|
||||
Ini iniData;
|
||||
ESVApi esv;
|
||||
|
||||
|
@ -98,7 +94,6 @@ run(string[] args)
|
|||
"H", &HFlag, "h", &hFlag,
|
||||
"l", &lFlag,
|
||||
"N", &NFlag, "n", &nFlag,
|
||||
"P", &PFlag,
|
||||
"R", &RFlag, "r", &rFlag,
|
||||
"s", &sFlag,
|
||||
"V", &VFlag,
|
||||
|
@ -126,7 +121,7 @@ run(string[] args)
|
|||
}
|
||||
|
||||
if (args.length < 3) {
|
||||
stderr.writefln("usage: %s [-aFfHhNnPRrV] [-C config] [-l length] [-s query] book verses", args[0].baseName());
|
||||
stderr.writefln("usage: %s [-aFfHhNnRrV] [-C config] [-l length] [-s query] book verses", args[0].baseName());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -259,35 +254,7 @@ key = %s
|
|||
if (RFlag) esv.opts.b["include-passage-references"] = false;
|
||||
if (lFlag != 0) esv.opts.i["line-length"] = lFlag;
|
||||
|
||||
verses = esv.getPassage(args[1].parseBook(), args[2]);
|
||||
foreach (string line; verses.splitLines())
|
||||
++lines;
|
||||
|
||||
/* If the passage is very long, pipe it into a pager */
|
||||
if (lines > 32 && !PFlag) {
|
||||
import std.process : pipeProcess, Redirect, wait, ProcessException;
|
||||
|
||||
pager = environment.get(ENV_PAGER, DEFAULT_PAGER);
|
||||
try {
|
||||
auto pipe = pipeProcess(pager, Redirect.stdin);
|
||||
pipe.stdin.writeln(verses);
|
||||
pipe.stdin.flush();
|
||||
pipe.stdin.close();
|
||||
pipe.pid.wait();
|
||||
} catch (ProcessException e) {
|
||||
enforce(e.msg.matchFirst(regex("^Executable file not found")).empty,
|
||||
format!"%s: command not found"(e.msg
|
||||
.matchFirst(": (.+)$")[0]
|
||||
.replaceFirst(regex("^: "), "")
|
||||
));
|
||||
|
||||
throw new Exception(e.msg); /* catch-all */
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
writeln(verses);
|
||||
writeln(esv.getPassage(args[1].parseBook(), args[2]));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue