MCPcopy Create free account
hub / github.com/MayaPosch/NymphCast / main

Function main

src/client/NymphCastClient.cpp:60–160  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

58
59
60int main(int argc, char *argv[]) {
61 // Parse the command line arguments.
62 Sarge sarge;
63 sarge.setArgument("h", "help", "Get this help message.", false);
64 sarge.setArgument("v", "version", "Output the NymphCast client version and exit.", false);
65 sarge.setArgument("r", "remotes", "Display online NymphCast receivers and quit.", false);
66 sarge.setArgument("f", "file", "Name of file to stream to remote receiver.", true);
67 sarge.setArgument("i", "ip", "IP address of the target NymphCast receiver.", true);
68 sarge.setDescription("NymphCast client application. For use with NymphCast servers. More details: http://nyanko.ws/nymphcast.php.");
69 sarge.setUsage("nymphcast_client <options>");
70
71 sarge.parseArguments(argc, argv);
72
73 if (sarge.flagCount() == 0) {
74 sarge.printHelp();
75 return 0;
76 }
77
78 if (sarge.exists("help")) {
79 sarge.printHelp();
80 return 0;
81 }
82
83 if (sarge.exists("version")) {
84 std::cout << "NymphCast client version: " << __VERSION << std::endl;
85 return 0;
86 }
87
88 // We need access to the NymphCast client library from this point.
89 NymphCastClient client;
90
91 if (sarge.exists("remotes")) {
92 std::cout << "Scanning for online remote receivers..." << std::endl;
93
94 std::vector remotes = client.findServers();
95 if (remotes.size() < 1) {
96 std::cout << "No remotes found." << std::endl;
97 return 0;
98 }
99
100 // Print out list of remotes.
101 std::cout << "Found remotes:" << std::endl;
102 for (int i = 0; i < remotes.size(); ++i) {
103 std::cout << i << ". " << remotes[i].name << " <" << remotes[i].ipv4 << ":"
104 << remotes[i].port << "> (" << remotes[i].ipv6 << ")"
105 << std::endl;
106 }
107
108 return 0;
109 }
110
111 // Enter command processing loop.
112 // If the 'file' flag is set, start by playing back the file, optionally using the provided IP.
113
114 // Allow the IP address of the server to be passed on the command line.
115 // Try to open the file.
116 std::string filename;
117 std::string serverip = "127.0.0.1";

Callers

nothing calls this directly

Calls 15

findServersMethod · 0.80
lengthMethod · 0.80
connectServerMethod · 0.80
lockMethod · 0.80
waitMethod · 0.80
disconnectServerMethod · 0.80
setArgumentMethod · 0.45
setDescriptionMethod · 0.45
setUsageMethod · 0.45
parseArgumentsMethod · 0.45
flagCountMethod · 0.45
printHelpMethod · 0.45

Tested by

no test coverage detected