Skip to content

Commit

Permalink
add argument handling to snapshot.topaz (yikes) ... incorrectly extra…
Browse files Browse the repository at this point in the history
…cting values from options
  • Loading branch information
dalehenrich committed Oct 28, 2023
1 parent 74212c9 commit b9694e3
Showing 1 changed file with 33 additions and 3 deletions.
36 changes: 33 additions & 3 deletions bin/snapshot.topaz
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
set u SystemUser p swordfish

login
run
GsFile stdout nextPutAll: 'hi'; lf.
%

run
"
Expand All @@ -22,11 +25,38 @@ run
The default snapshot directory is a sibling directory of the backup directory
named 'snapshot'.
"
| snapshots suspendInMinutes safely snapshotExtension snapshotPath |
| scriptArgIndex args snapshots suspendInMinutes safely snapshotExtension snapshotPath optionMap |
args := System commandLineArguments.
suspendInMinutes := 15.
safely := true.
snapshotExtension := 'test.dbf'.
snapshotPath := '/bosch1/users/dhenrich/_stones/bosch_36x/stones/gs_367/snapshots'.
scriptArgIndex := args indexOf: '--'.
scriptArgIndex > 0
ifTrue: [
| block |
block := [:optionString :theOption :map |
| index theArg |
theArg := '--', theOption, '='.
(index := theArg findString: optionString startingAt: 1) > 0
ifTrue: [
| stream value |
stream := ReadStream on: (theArg copyFrom: index + optionString size to: theArg size).
value := stream upTo: Character space.
map at: optionString put: value ] ].
args := args copyFrom: scriptArgIndex + 1 to: args size.
optionMap := Dictionary new.
args do: [:each |
block value: 'suspend' value: each value: optionMap.
block value: 'safely' value: each value: optionMap.
block value: 'extension' value: each value: optionMap.
block value: 'snapshotPath' value: each value: optionMap ].
optionMap at: 'safely' ifPresent: [:val | safely := val ].
optionMap at: 'suspend' ifPresent: [:val | suspendInMinutes := val asNumber ].
optionMap at: 'extension' ifPresent: [:val | snapshotExtension := val ].
optionMap at: 'snapshotPath' ifPresent: [:val | snapshotPath := val ] ]
ifFalse: [
self halt.
snapshotExtension := 'test.dbf'.
snapshotPath := '/bosch1/users/dhenrich/_stones/bosch_36x/stones/gs_367/snapshots' ].
"=========================================================================="
[
System commitTransaction
Expand Down

0 comments on commit b9694e3

Please sign in to comment.