Change default config location.

v0.3
Martin Dosch 2 years ago
parent fdd57eb82c
commit 469495d556

@ -8,6 +8,7 @@
- Removed invalid code points from input.
- Fixed crash when reading a config with wrong syntax.
- Fixed crash when a non-existing or non-readable config was supplied by `-f`.
- Changed config file location from `~/.config/go-sendxmpp/sendxmpprc` to `~/.config/go-sendxmpp/config`.
## [v0.2.0]
### Added

@ -49,7 +49,7 @@ There are some (automatically built and untested) binaries linked to the
You can either pipe a programs output to `go-sendxmpp`, write in your terminal (put \^D in a new
line to finish) or send the input from a file (`-m` or `--message`).
The account data is expected at `~/.config/go-sendxmpp/sendxmpprc` if no other configuration file location
The account data is expected at `~/.config/go-sendxmpp/config` if no other configuration file location
is specified with `-f` or `--file`. The configuration file is expected to be in the following format:
```plain

@ -46,23 +46,30 @@ func parseConfig(configPath string) (configuration, error) {
err error
)
// Use $XDG_CONFIG_HOME/.config/go-sendxmpp/sendxmpprc or
// Use $XDG_CONFIG_HOME/.config/go-sendxmpp/config,
// $XDG_CONFIG_HOME/.config/go-sendxmpp/sendxmpprc or
// ~/.sendxmpprc if no config path is specified.
if configPath == "" {
// Get systems user config path.
osConfigDir := os.Getenv("$XDG_CONFIG_HOME")
if osConfigDir != "" {
configPath = osConfigDir + "/go-sendxmpp/sendxmpprc"
configPath = osConfigDir + "/go-sendxmpp/config"
// Check that the config file is existing.
_, err := os.Stat(configPath)
if os.IsNotExist(err) {
// If the file is not existing at ~/.config/go-sendxmpp/sendxmpprc
// check at the perl sendxmpp legacy destination.
configPath = osConfigDir + "/.sendxmpprc"
// If the file is not existing at ~/.config/go-sendxmpp/config
// check at the previous config file destination.
configPath = osConfigDir + "/go-sendxmpp/sendxmpprc"
_, err = os.Stat(configPath)
if os.IsNotExist(err) {
return output, errors.New("no configuration file found")
// If the file is not existing at ~/.config/go-sendxmpp/sendxmpprc
// check at the perl sendxmpp legacy destination.
configPath = osConfigDir + "/.sendxmpprc"
_, err = os.Stat(configPath)
if os.IsNotExist(err) {
return output, errors.New("no configuration file found")
}
}
}
} else {
@ -76,19 +83,25 @@ func parseConfig(configPath string) (configuration, error) {
if home == "" {
return output, errors.New("no home directory found")
}
configPath = home + "/.config/go-sendxmpp/sendxmpprc"
configPath = home + "/.config/go-sendxmpp/config"
// Check that config file is existing.
_, err = os.Stat(configPath)
if os.IsNotExist(err) {
// If the file is not existing at ~/.config/go-sendxmpp/sendxmpprc
// check at the perl sendxmpp legacy destination.
configPath = home + "/.sendxmpprc"
// If the file is not existing at ~/.config/go-sendxmpp/config
// check at the previous config file destination.
configPath = home + "/.config/go-sendxmpp/sendxmpprc"
// Check that config file is existing.
_, err = os.Stat(configPath)
if os.IsNotExist(err) {
return output, errors.New("no configuration file found")
// If the file is not existing at ~/.config/go-sendxmpp/sendxmpprc
// check at the perl sendxmpp legacy destination.
configPath = home + "/.sendxmpprc"
_, err = os.Stat(configPath)
if os.IsNotExist(err) {
return output, errors.New("no configuration file found")
}
}
}
}
}

@ -8,13 +8,13 @@
.SH "DESCRIPTION"
A little tool to send messages to an XMPP contact or MUC inspired by (but not as powerful as) \fBsendxmpp\fR\.
.br
You can either pipe a programs output to \fBgo\-sendxmpp\fR, write in your terminal (put \fB^D\fR in a new line to finish) or send the input from a file (\fB\-m\fR or \fB\-\-message\fR)\. The account data is expected at \fB~/\.config/go\-sendxmpp/sendxmpprc\fR (preferred) or \fB~/\.sendxmpprc\fR (for compatibility with the original perl sendxmpp) if no other configuration file location is specified with \fB\-f\fR or \fB\-\-file\fR\.
You can either pipe a programs output to \fBgo\-sendxmpp\fR, write in your terminal (put \fB^D\fR in a new line to finish) or send the input from a file (\fB\-m\fR or \fB\-\-message\fR)\. The account data is expected at \fB~/\.config/go\-sendxmpp/config\fR (preferred), \fB~/\.config/go\-sendxmpp/sendxmpprc (deprecated)\fR~/\.sendxmpprc\fB(for compatibility with the original perl sendxmpp) if no other configuration file location is specified with\fR\-f\fBor\fR\-\-file`\.
.SH "OPTIONS"
\fB\-c\fR, \fB\-\-chatroom\fR=[\fIvalue\fR]: Send message to a chatroom\.
.P
\fB\-d\fR, \fB\-\-debug\fR: Show debugging info\.
.P
\fB\-f\fR, \fB\-\-file\fR=[\fIvalue\fR]: Set configuration file\. (Default: ~/\.sendxmpprc)
\fB\-f\fR, \fB\-\-file\fR=[\fIvalue\fR]: Set configuration file\. (Default: ~/\.config/go\-sendxmpp/config)
.P
\fB\-\-help\fR: Show help\.
.P

@ -85,9 +85,9 @@
<p>A little tool to send messages to an XMPP contact or MUC inspired by (but not as powerful as) <code>sendxmpp</code>. <br>
You can either pipe a programs output to <code>go-sendxmpp</code>, write in your terminal (put <code>^D</code> in a new line to
finish) or send the input from a file (<code>-m</code> or <code>--message</code>).
The account data is expected at <code>~/.config/go-sendxmpp/sendxmpprc</code> (preferred) or <code>~/.sendxmpprc</code> (for
compatibility with the original perl sendxmpp) if no other configuration file location is specified with
<code>-f</code> or <code>--file</code>.</p>
The account data is expected at <code>~/.config/go-sendxmpp/config</code> (preferred), <code>~/.config/go-sendxmpp/sendxmpprc
(deprecated)</code>~/.sendxmpprc<code> (for compatibility with the original perl sendxmpp) if no other configuration
file location is specified with </code>-f<code> or </code>--file`.</p>
<h2 id="OPTIONS">OPTIONS</h2>
@ -98,7 +98,7 @@ compatibility with the original perl sendxmpp) if no other configuration file lo
Show debugging info.</p>
<p><code>-f</code>, <code>--file</code>=[<var>value</var>]:
Set configuration file. (Default: ~/.sendxmpprc)</p>
Set configuration file. (Default: ~/.config/go-sendxmpp/config)</p>
<p><code>--help</code>:
Show help.</p>
@ -168,7 +168,7 @@ License: BSD 2-clause License</p>
<h2 id="SEE-ALSO">SEE ALSO</h2>
<p><span class="man-ref">go-sendxmpp<span class="s">(5)</span></span>, <span class="man-ref">sendxmpp<span class="s">(1)</span></span></p>
<p><a class="man-ref" href="go-sendxmpp.5.html">go-sendxmpp<span class="s">(5)</span></a>, <span class="man-ref">sendxmpp<span class="s">(1)</span></span></p>
<ol class='man-decor man-foot man foot'>
<li class='tl'></li>

@ -10,9 +10,9 @@ go-sendxmpp(1) -- A little tool to send messages to an XMPP contact or MUC.
A little tool to send messages to an XMPP contact or MUC inspired by (but not as powerful as) `sendxmpp`.
You can either pipe a programs output to `go-sendxmpp`, write in your terminal (put `^D` in a new line to
finish) or send the input from a file (`-m` or `--message`).
The account data is expected at `~/.config/go-sendxmpp/sendxmpprc` (preferred) or `~/.sendxmpprc` (for
compatibility with the original perl sendxmpp) if no other configuration file location is specified with
`-f` or `--file`.
The account data is expected at `~/.config/go-sendxmpp/config` (preferred), `~/.config/go-sendxmpp/sendxmpprc
(deprecated)`~/.sendxmpprc` (for compatibility with the original perl sendxmpp) if no other configuration
file location is specified with `-f` or `--file`.
## OPTIONS
@ -23,7 +23,7 @@ compatibility with the original perl sendxmpp) if no other configuration file lo
Show debugging info.
`-f`, `--file`=[<value>]:
Set configuration file. (Default: ~/.sendxmpprc)
Set configuration file. (Default: ~/.config/go-sendxmpp/config)
`--help`:
Show help.

@ -4,7 +4,7 @@
.SH "NAME"
\fBgo\-sendxmpp\fR \- A little tool to send messages to an XMPP contact or MUC\.
.SH "LOCATION"
The account data is expected at ~/\.config/go\-sendxmpp/sendxmpprc (preferred) or ~/\.sendxmpprc (for compatibility with the original perl sendxmpp) if no other configuration file location is specified with \-f or \-\-file\. The configuration file is expected to be in the following format:
The account data is expected at \fB~/\.config/go\-sendxmpp/config\fR (preferred), \fB~/\.config/go\-sendxmpp/sendxmpprc\fR deprecated) or \fB~/\.sendxmpprc\fR (for compatibility with the original perl sendxmpp) if no other configuration file location is specified with \-f or \-\-file\. The configuration file is expected to be in the following format:
.SH "FORMAT"
username: [\fIyour_jid\fR]
.br

@ -77,9 +77,9 @@
</p>
<h2 id="LOCATION">LOCATION</h2>
<p>The account data is expected at ~/.config/go-sendxmpp/sendxmpprc (preferred) or ~/.sendxmpprc
(for compatibility with the original perl sendxmpp) if no other configuration file location is
specified with -f or --file. The configuration file is expected to be in the following format:</p>
<p>The account data is expected at <code>~/.config/go-sendxmpp/config</code> (preferred), <code>~/.config/go-sendxmpp/sendxmpprc</code>
deprecated) or <code>~/.sendxmpprc</code> (for compatibility with the original perl sendxmpp) if no other configuration file
location is specified with -f or --file. The configuration file is expected to be in the following format:</p>
<h2 id="FORMAT">FORMAT</h2>
@ -112,7 +112,7 @@ License: BSD 2-clause License</p>
<h2 id="SEE-ALSO">SEE ALSO</h2>
<p><span class="man-ref">go-sendxmpp<span class="s">(1)</span></span>, <span class="man-ref">sendxmpp<span class="s">(1)</span></span></p>
<p><a class="man-ref" href="go-sendxmpp.1.html">go-sendxmpp<span class="s">(1)</span></a>, <span class="man-ref">sendxmpp<span class="s">(1)</span></span></p>
<ol class='man-decor man-foot man foot'>
<li class='tl'></li>

@ -3,9 +3,9 @@ go-sendxmpp(5) -- A little tool to send messages to an XMPP contact or MUC.
## LOCATION
The account data is expected at ~/.config/go-sendxmpp/sendxmpprc (preferred) or ~/.sendxmpprc
(for compatibility with the original perl sendxmpp) if no other configuration file location is
specified with -f or --file. The configuration file is expected to be in the following format:
The account data is expected at `~/.config/go-sendxmpp/config` (preferred), `~/.config/go-sendxmpp/sendxmpprc`
deprecated) or `~/.sendxmpprc` (for compatibility with the original perl sendxmpp) if no other configuration file
location is specified with -f or --file. The configuration file is expected to be in the following format:
## FORMAT

Loading…
Cancel
Save