-
Notifications
You must be signed in to change notification settings - Fork 28
/
command_line.go
48 lines (42 loc) · 1020 Bytes
/
command_line.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
//----------------------------------------
//
// Copyright © yanghy. All Rights Reserved.
//
// Licensed under Apache License Version 2.0, January 2004
//
// https://www.apache.org/licenses/LICENSE-2.0
//
//----------------------------------------
// CEF 进程命令行
package cef
import (
"bytes"
"strings"
)
func (m *TCefCommandLine) AppendSwitch(name, value string) {
m.commandLines[name] = value
}
func (m *TCefCommandLine) AppendArgument(argument string) {
m.commandLines[argument] = ""
}
func (m *TCefCommandLine) toString() string {
var str bytes.Buffer
var i = 0
var replace = func(s, old, new string) string {
return strings.Replace(s, old, new, -1)
}
for name, value := range m.commandLines {
if i > 0 {
str.WriteString(" ")
}
if value != "" {
str.WriteString(replace(replace(name, " ", ""), "=", ""))
str.WriteString("=")
str.WriteString(replace(replace(value, " ", ""), "=", ""))
} else {
str.WriteString(replace(name, " ", ""))
}
i++
}
return str.String()
}