CLAP - how to get instance of command without executing it

B
bajger@gmail.com
Sat, Dec 25, 2021 9:07 AM

Hi Pharoers!

I have following problem in CLAP and would be glad to get your guidance: I have following method on command class (sub-class of ClapApplication):
PhLImageKillCliCommand>>osShellCmdString

(arguments at: #all) value

ifTrue: [ ^ (self killImageCmdStringFrom: nil) ].

^ self killImageCmdStringFrom: self imageName

And I want to implement unit test, that would test expected output of this method. As you can see, implementation is dependent on arguments attribute #all. And here is a problem in unit test:

testOsShellCmdString
`| killCliCommand  aMatch|

aMatch := (context arguments: #('launcher' 'image' 'kill' '--all')) match.
killCliCommand :=  PhLImageKillCliCommand new.

killCliCommand setArguments: aMatch.`

`self assert: killCliCommand osShellCmdString equals: ''.`

This doesn't work, since arguments at: #all gives NotYetImplemented exception. So I don't know, how to "wire" toghether instance of command (without executing it) and needed arguments (a match). Any advice on this?

Obrázek

Hi Pharoers! I have following problem in CLAP and would be glad to get your guidance: I have following method on command class (sub-class of ClapApplication):\ `PhLImageKillCliCommand>>osShellCmdString` `(arguments at: #all) value ` ` ifTrue: [ ^ (self killImageCmdStringFrom: nil) ]. ` `^ self killImageCmdStringFrom: self imageName` And I want to implement unit test, that would test expected output of this method. As you can see, implementation is dependent on arguments attribute #all. And here is a problem in unit test: `testOsShellCmdString`\ `| killCliCommand aMatch| aMatch := (context arguments: #('launcher' 'image' 'kill' '--all')) match. killCliCommand := PhLImageKillCliCommand new. killCliCommand setArguments: aMatch.` `self assert: killCliCommand osShellCmdString equals: ''.` This doesn't work, since `arguments at: #all` gives NotYetImplemented exception. So I don't know, how to "wire" toghether instance of command (without executing it) and needed arguments (a match). Any advice on this? ![Obrázek](https://media.discordapp.net/attachments/819245127310114886/922498381358723123/unknown.png)