Skip to content

Commit e9f927d

Browse files
committed
Fix #396, Add config cmd
1 parent a8a031e commit e9f927d

File tree

9 files changed

+249
-130
lines changed

9 files changed

+249
-130
lines changed

cmd/pdfcpu/cmd.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ func validateConfigDirFlag() {
101101

102102
func ensureDefaultConfig() (*pdfcpu.Configuration, error) {
103103
validateConfigDirFlag()
104-
//fmt.Printf("conf = %s\n", pdfcpu.ConfigPath)
105104
if !pdfcpu.MemberOf(pdfcpu.ConfigPath, []string{"default", "disable"}) {
106105
if err := pdfcpu.EnsureDefaultConfigAt(pdfcpu.ConfigPath); err != nil {
107106
return nil, err

cmd/pdfcpu/init.go

Lines changed: 38 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -50,21 +50,37 @@ func initCommandMap() {
5050
boxesCmdMap.register(k, v)
5151
}
5252

53+
fontsCmdMap := newCommandMap()
54+
for k, v := range map[string]command{
55+
"cheatsheet": {processCreateCheatSheetFontsCommand, nil, "", ""},
56+
"install": {processInstallFontsCommand, nil, "", ""},
57+
"list": {processListFontsCommand, nil, "", ""},
58+
} {
59+
fontsCmdMap.register(k, v)
60+
}
61+
5362
imagesCmdMap := newCommandMap()
5463
for k, v := range map[string]command{
5564
"list": {processListImagesCommand, nil, "", ""},
5665
} {
5766
imagesCmdMap.register(k, v)
5867
}
5968

60-
portfolioCmdMap := newCommandMap()
69+
keywordsCmdMap := newCommandMap()
6170
for k, v := range map[string]command{
62-
"list": {processListAttachmentsCommand, nil, "", ""},
63-
"add": {processAddAttachmentsPortfolioCommand, nil, "", ""},
64-
"remove": {processRemoveAttachmentsCommand, nil, "", ""},
65-
"extract": {processExtractAttachmentsCommand, nil, "", ""},
71+
"list": {processListKeywordsCommand, nil, "", ""},
72+
"add": {processAddKeywordsCommand, nil, "", ""},
73+
"remove": {processRemoveKeywordsCommand, nil, "", ""},
6674
} {
67-
portfolioCmdMap.register(k, v)
75+
keywordsCmdMap.register(k, v)
76+
}
77+
78+
pagesCmdMap := newCommandMap()
79+
for k, v := range map[string]command{
80+
"insert": {processInsertPagesCommand, nil, "", ""},
81+
"remove": {processRemovePagesCommand, nil, "", ""},
82+
} {
83+
pagesCmdMap.register(k, v)
6884
}
6985

7086
permissionsCmdMap := newCommandMap()
@@ -75,12 +91,23 @@ func initCommandMap() {
7591
permissionsCmdMap.register(k, v)
7692
}
7793

78-
pagesCmdMap := newCommandMap()
94+
portfolioCmdMap := newCommandMap()
7995
for k, v := range map[string]command{
80-
"insert": {processInsertPagesCommand, nil, "", ""},
81-
"remove": {processRemovePagesCommand, nil, "", ""},
96+
"list": {processListAttachmentsCommand, nil, "", ""},
97+
"add": {processAddAttachmentsPortfolioCommand, nil, "", ""},
98+
"remove": {processRemoveAttachmentsCommand, nil, "", ""},
99+
"extract": {processExtractAttachmentsCommand, nil, "", ""},
82100
} {
83-
pagesCmdMap.register(k, v)
101+
portfolioCmdMap.register(k, v)
102+
}
103+
104+
propertiesCmdMap := newCommandMap()
105+
for k, v := range map[string]command{
106+
"list": {processListPropertiesCommand, nil, "", ""},
107+
"add": {processAddPropertiesCommand, nil, "", ""},
108+
"remove": {processRemovePropertiesCommand, nil, "", ""},
109+
} {
110+
propertiesCmdMap.register(k, v)
84111
}
85112

86113
stampCmdMap := newCommandMap()
@@ -101,33 +128,6 @@ func initCommandMap() {
101128
watermarkCmdMap.register(k, v)
102129
}
103130

104-
fontsCmdMap := newCommandMap()
105-
for k, v := range map[string]command{
106-
"cheatsheet": {processCreateCheatSheetFontsCommand, nil, "", ""},
107-
"install": {processInstallFontsCommand, nil, "", ""},
108-
"list": {processListFontsCommand, nil, "", ""},
109-
} {
110-
fontsCmdMap.register(k, v)
111-
}
112-
113-
keywordsCmdMap := newCommandMap()
114-
for k, v := range map[string]command{
115-
"list": {processListKeywordsCommand, nil, "", ""},
116-
"add": {processAddKeywordsCommand, nil, "", ""},
117-
"remove": {processRemoveKeywordsCommand, nil, "", ""},
118-
} {
119-
keywordsCmdMap.register(k, v)
120-
}
121-
122-
propertiesCmdMap := newCommandMap()
123-
for k, v := range map[string]command{
124-
"list": {processListPropertiesCommand, nil, "", ""},
125-
"add": {processAddPropertiesCommand, nil, "", ""},
126-
"remove": {processRemovePropertiesCommand, nil, "", ""},
127-
} {
128-
propertiesCmdMap.register(k, v)
129-
}
130-
131131
cmdMap = newCommandMap()
132132

133133
for k, v := range map[string]command{
@@ -138,6 +138,7 @@ func initCommandMap() {
138138
"changeopw": {processChangeOwnerPasswordCommand, nil, usageChangeOwnerPW, usageLongChangeUserPW},
139139
"changeupw": {processChangeUserPasswordCommand, nil, usageChangeUserPW, usageLongChangeUserPW},
140140
"collect": {processCollectCommand, nil, usageCollect, usageLongCollect},
141+
"config": {printConfiguration, nil, usageConfig, usageLongConfig},
141142
"create": {processCreateCommand, nil, usageCreate, usageLongCreate},
142143
"crop": {processCropCommand, nil, usageCrop, usageLongCrop},
143144
"decrypt": {processDecryptCommand, nil, usageDecrypt, usageLongDecrypt},

0 commit comments

Comments
 (0)