Config now loads default values from a file alongside the source.

This commit is contained in:
Michael Lazar
2015-12-14 23:37:23 -08:00
parent b487f70e48
commit 49e2d1aa4f
8 changed files with 196 additions and 83 deletions

View File

@@ -56,8 +56,8 @@ def main():
data['copyright'] = rtv.__copyright__
# Escape dashes is all of the sections
data = {k: v.replace('-', r'\-') for k, v in data.items()}
print('Reading from %s/rtv/templates/rtv.1.template' % ROOT)
with open(os.path.join(ROOT, 'rtv/templates/rtv.1.template')) as fp:
print('Reading from %s/rtv/scripts/rtv.1.template' % ROOT)
with open(os.path.join(ROOT, 'rtv/scripts/rtv.1.template')) as fp:
template = fp.read()
print('Populating template')
out = template.format(**data)

40
scripts/rtv.1.template Normal file
View File

@@ -0,0 +1,40 @@
.TH "RTV" "1" "{release_date}" "Version {version}" "Usage and Commands"
.SH NAME
RTV - Reddit Terminal Viewer
.SH SYNOPSIS
{synopsis}
.SH DESCRIPTION
{description}
.SH OPTIONS
{options}
.SH CONTROLS
Navigate between posts by using the arrow keys or vim-style `hjkl` movement.
You can view the full list of commands by pressing the \fB?\fR key inside of the program.
.SH FILES
.TP
.BR $XDG_CONFIG_HOME/rtv/rtv.cfg
The configuration file can be used to customize default program settings, see
README.rst for more information.
.TP
.BR $XDG_CONFIG_HOME/rtv/refresh-token
After you login to reddit, your most recent OAuth refresh token will be stored
for future sessions. You can disable this behavior by setting the option
\fBpersistent=False\fR in your configuration file.
.SH ENVIRONMENT
.TP
.BR RTV_EDITOR
Specifies which text editor RTV will attempt to use when editing comments and
posts. RTV will fallback to \fI$EDITOR\fR if the editor is unspecified.
.TP
.BR BROWSER
Specifies which webbrowser RTV will attempt to use when opening links.
This can be set to a terminal browser (w3m, lynx, elinks, etc.) for a true
terminal experience. RTV will fallback to the system's default browser.
.SH AUTHOR
Man page written by Johnathan "ShaggyTwoDope" Jenkins <twodopeshaggy@gmail.com> (2015).
.SH BUGS
Report bugs to \fIhttps://github.com/michael-lazar/rtv/issues\fR
.SH LICENSE
{license}
.PP
{copyright}