Skip to content

Commit

Permalink
Fix #396, Add config cmd
Browse files Browse the repository at this point in the history
  • Loading branch information
hhrutter committed Dec 4, 2021
1 parent a8a031e commit e9f927d
Show file tree
Hide file tree
Showing 9 changed files with 249 additions and 130 deletions.
1 change: 0 additions & 1 deletion cmd/pdfcpu/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ func validateConfigDirFlag() {

func ensureDefaultConfig() (*pdfcpu.Configuration, error) {
validateConfigDirFlag()
//fmt.Printf("conf = %s\n", pdfcpu.ConfigPath)
if !pdfcpu.MemberOf(pdfcpu.ConfigPath, []string{"default", "disable"}) {
if err := pdfcpu.EnsureDefaultConfigAt(pdfcpu.ConfigPath); err != nil {
return nil, err
Expand Down
75 changes: 38 additions & 37 deletions cmd/pdfcpu/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,21 +50,37 @@ func initCommandMap() {
boxesCmdMap.register(k, v)
}

fontsCmdMap := newCommandMap()
for k, v := range map[string]command{
"cheatsheet": {processCreateCheatSheetFontsCommand, nil, "", ""},
"install": {processInstallFontsCommand, nil, "", ""},
"list": {processListFontsCommand, nil, "", ""},
} {
fontsCmdMap.register(k, v)
}

imagesCmdMap := newCommandMap()
for k, v := range map[string]command{
"list": {processListImagesCommand, nil, "", ""},
} {
imagesCmdMap.register(k, v)
}

portfolioCmdMap := newCommandMap()
keywordsCmdMap := newCommandMap()
for k, v := range map[string]command{
"list": {processListAttachmentsCommand, nil, "", ""},
"add": {processAddAttachmentsPortfolioCommand, nil, "", ""},
"remove": {processRemoveAttachmentsCommand, nil, "", ""},
"extract": {processExtractAttachmentsCommand, nil, "", ""},
"list": {processListKeywordsCommand, nil, "", ""},
"add": {processAddKeywordsCommand, nil, "", ""},
"remove": {processRemoveKeywordsCommand, nil, "", ""},
} {
portfolioCmdMap.register(k, v)
keywordsCmdMap.register(k, v)
}

pagesCmdMap := newCommandMap()
for k, v := range map[string]command{
"insert": {processInsertPagesCommand, nil, "", ""},
"remove": {processRemovePagesCommand, nil, "", ""},
} {
pagesCmdMap.register(k, v)
}

permissionsCmdMap := newCommandMap()
Expand All @@ -75,12 +91,23 @@ func initCommandMap() {
permissionsCmdMap.register(k, v)
}

pagesCmdMap := newCommandMap()
portfolioCmdMap := newCommandMap()
for k, v := range map[string]command{
"insert": {processInsertPagesCommand, nil, "", ""},
"remove": {processRemovePagesCommand, nil, "", ""},
"list": {processListAttachmentsCommand, nil, "", ""},
"add": {processAddAttachmentsPortfolioCommand, nil, "", ""},
"remove": {processRemoveAttachmentsCommand, nil, "", ""},
"extract": {processExtractAttachmentsCommand, nil, "", ""},
} {
pagesCmdMap.register(k, v)
portfolioCmdMap.register(k, v)
}

propertiesCmdMap := newCommandMap()
for k, v := range map[string]command{
"list": {processListPropertiesCommand, nil, "", ""},
"add": {processAddPropertiesCommand, nil, "", ""},
"remove": {processRemovePropertiesCommand, nil, "", ""},
} {
propertiesCmdMap.register(k, v)
}

stampCmdMap := newCommandMap()
Expand All @@ -101,33 +128,6 @@ func initCommandMap() {
watermarkCmdMap.register(k, v)
}

fontsCmdMap := newCommandMap()
for k, v := range map[string]command{
"cheatsheet": {processCreateCheatSheetFontsCommand, nil, "", ""},
"install": {processInstallFontsCommand, nil, "", ""},
"list": {processListFontsCommand, nil, "", ""},
} {
fontsCmdMap.register(k, v)
}

keywordsCmdMap := newCommandMap()
for k, v := range map[string]command{
"list": {processListKeywordsCommand, nil, "", ""},
"add": {processAddKeywordsCommand, nil, "", ""},
"remove": {processRemoveKeywordsCommand, nil, "", ""},
} {
keywordsCmdMap.register(k, v)
}

propertiesCmdMap := newCommandMap()
for k, v := range map[string]command{
"list": {processListPropertiesCommand, nil, "", ""},
"add": {processAddPropertiesCommand, nil, "", ""},
"remove": {processRemovePropertiesCommand, nil, "", ""},
} {
propertiesCmdMap.register(k, v)
}

cmdMap = newCommandMap()

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

0 comments on commit e9f927d

Please sign in to comment.