Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
6c239f7a
Commit
6c239f7a
authored
Jan 17, 2018
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test/run_input: add option to load a configuration file
parent
7d5b8597
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
4 deletions
+25
-4
run_input.cxx
test/run_input.cxx
+25
-4
No files found.
test/run_input.cxx
View file @
6c239f7a
...
...
@@ -26,9 +26,11 @@
#include "event/Thread.hxx"
#include "thread/Cond.hxx"
#include "Log.hxx"
#include "fs/Path.hxx"
#include "fs/io/BufferedOutputStream.hxx"
#include "fs/io/StdioOutputStream.hxx"
#include "util/ConstBuffer.hxx"
#include "util/OptionDef.hxx"
#include "util/OptionParser.hxx"
#ifdef ENABLE_ARCHIVE
...
...
@@ -42,6 +44,16 @@
struct
CommandLine
{
const
char
*
uri
=
nullptr
;
Path
config_path
=
Path
::
Null
();
};
enum
Option
{
OPTION_CONFIG
,
};
static
constexpr
OptionDef
option_defs
[]
=
{
{
"config"
,
0
,
true
,
"Load a MPD configuration file"
},
};
static
CommandLine
...
...
@@ -49,13 +61,18 @@ ParseCommandLine(int argc, char **argv)
{
CommandLine
c
;
OptionParser
option_parser
(
nullptr
,
argc
,
argv
);
OptionParser
option_parser
(
option_defs
,
argc
,
argv
);
while
(
auto
o
=
option_parser
.
Next
())
{
switch
(
Option
(
o
.
index
))
{
case
OPTION_CONFIG
:
c
.
config_path
=
Path
::
FromFS
(
o
.
value
);
break
;
}
}
auto
args
=
option_parser
.
GetRemaining
();
if
(
args
.
size
!=
1
)
throw
std
::
runtime_error
(
"Usage: run_input URI"
);
throw
std
::
runtime_error
(
"Usage: run_input
[--config=FILE]
URI"
);
c
.
uri
=
args
.
front
();
return
c
;
...
...
@@ -65,9 +82,13 @@ class GlobalInit {
EventThread
io_thread
;
public
:
GlobalInit
()
{
GlobalInit
(
Path
config_path
)
{
io_thread
.
Start
();
config_global_init
();
if
(
!
config_path
.
IsNull
())
ReadConfigFile
(
config_path
);
#ifdef ENABLE_ARCHIVE
archive_plugin_init_all
();
#endif
...
...
@@ -134,7 +155,7 @@ try {
/* initialize MPD */
const
GlobalInit
init
;
const
GlobalInit
init
(
c
.
config_path
)
;
/* open the stream and dump it */
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment