From fe03b65c8bd952ac26a516e23f4c04bb014455e9 Mon Sep 17 00:00:00 2001
From: Egor Tensin <Egor.Tensin@gmail.com>
Date: Fri, 16 Oct 2020 23:43:11 +0300
Subject: CommandLine: saner API

---
 include/winapi/cmd_line.hpp | 36 +++++++++++++++---------------------
 1 file changed, 15 insertions(+), 21 deletions(-)

(limited to 'include/winapi')

diff --git a/include/winapi/cmd_line.hpp b/include/winapi/cmd_line.hpp
index 60bc56a..176cf3d 100644
--- a/include/winapi/cmd_line.hpp
+++ b/include/winapi/cmd_line.hpp
@@ -17,7 +17,9 @@ class CommandLine {
 public:
     static CommandLine query();
 
-    static CommandLine build_from_main(int argc, wchar_t* argv[]);
+    static CommandLine parse(const std::string&);
+
+    static CommandLine from_main(int argc, wchar_t* argv[]);
 
     CommandLine() = default;
 
@@ -27,37 +29,29 @@ public:
     CommandLine(std::string&& argv0, std::vector<std::string>&& args = {})
         : argv0(std::move(argv0)), args(std::move(args)) {}
 
-    bool has_argv0() const { return !argv0.empty(); }
-
-    std::string get_argv0() const { return argv0; }
-
-    std::string escape_argv0() const { return escape(get_argv0()); }
+    static std::string escape(const std::string&);
 
-    bool has_args() const { return !get_args().empty(); }
+    static std::string escape_cmd(const std::string&);
 
-    const std::vector<std::string>& get_args() const { return args; }
+    std::string to_string() const;
 
-    std::vector<std::string> escape_args() const;
+    std::string args_to_string() const;
 
-    static BOOST_CONSTEXPR char sep() { return ' '; }
+    std::string get_argv0() const { return argv0; }
 
-    std::string join_args() const;
+    bool has_args() const { return !get_args().empty(); }
 
-    std::string join() const;
+    const std::vector<std::string>& get_args() const { return args; }
 
 private:
-    static CommandLine build_from_string(const std::string&);
-
-    static CommandLine build_from_string(std::wstring);
+    static BOOST_CONSTEXPR char token_sep() { return ' '; }
 
-    static std::string escape_for_cmd(const std::string&);
-
-    static std::string escape(const std::string&);
+    std::string escape_argv0() const { return escape(get_argv0()); }
 
-    CommandLine(std::vector<std::string>&& args) : args(std::move(args)) {}
+    std::vector<std::string> escape_args() const;
 
-    const std::string argv0;
-    const std::vector<std::string> args;
+    std::string argv0;
+    std::vector<std::string> args;
 };
 
 } // namespace winapi
-- 
cgit v1.2.3