-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
66 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* NeoPG | ||
Copyright 2017 The NeoPG developers | ||
NeoPG is released under the Simplified BSD License (see license.txt) | ||
*/ | ||
|
||
#include <iostream> | ||
|
||
#include <neopg-tool/curl_command.h> | ||
#include <neopg/http.h> | ||
|
||
namespace NeoPG { | ||
|
||
void CurlCommand::run() { | ||
NeoPG::Http request; | ||
request.set_url(m_url) | ||
.set_maxfilesize(m_max_filesize) | ||
.set_redirects(m_max_redirects) | ||
.no_cache(m_nocache); | ||
|
||
std::string response = request.fetch(); | ||
std::cout.write((const char*)response.data(), response.size()); | ||
} | ||
|
||
} // Namespace NeoPG |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* Command line parsing | ||
Copyright 2017 The NeoPG developers | ||
NeoPG is released under the Simplified BSD License (see license.txt) | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <neopg-tool/command.h> | ||
#include <neopg/http.h> | ||
|
||
namespace NeoPG { | ||
|
||
class CurlCommand : public Command { | ||
public: | ||
long m_max_filesize{NeoPG::Http::MAX_FILESIZE_DEFAULT}; | ||
long m_max_redirects{NeoPG::Http::MAX_REDIRECTS_DEFAULT}; | ||
bool m_nocache{false}; | ||
std::string m_url; | ||
void run() override; | ||
CurlCommand(CLI::App& app, const std::string& flag, | ||
const std::string& description, | ||
const std::string& group_name = "") | ||
: Command(app, flag, description, group_name) { | ||
m_cmd.add_option("url", m_url, "URL of resource to fetch")->required(); | ||
m_cmd.add_option("--max-redirs", m_max_redirects, | ||
"maximum number of redirects", true); | ||
m_cmd.add_option("--max-filesize", m_max_filesize, "maximum file size", | ||
true); | ||
m_cmd.add_flag("--no-cache", m_nocache, "do not use proxy data"); | ||
} | ||
}; | ||
|
||
} // Namespace NeoPG |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters