tmtsoftware / icd

ICD - Interface Control Document Management
Other
12 stars 5 forks source link

icd-db: Add "-y" argument to answer yes to all questions when in automated environment #56

Closed edwardchapin closed 6 years ago

edwardchapin commented 6 years ago

I am setting up Jenkins to auto-ingest each time our model file repo has changes. As part of this, I want to first drop the entire subsystem before re-ingesting (this is to cover things like renaming a component; I don't want the old version with a different name hanging around, and I don't want to touch the other subsystems).

This is the kind of thing I want to automate:

icd-db --drop component --subsystem NFIRAOS --component "*" && icd-db -i .

When I do the --drop in an interactive shell it asks me if I am sure. However, when I do this in Jenkins I get the following:

+ icd-db --drop component --subsystem NFIRAOS --component '*'
Are you sure you want to drop * from icds? [y/n] java.lang.NullPointerException
    at csw.services.icd.db.IcdDb$.confirmDrop$1(IcdDb.scala:188)
    at csw.services.icd.db.IcdDb$.drop$1(IcdDb.scala:176)
    at csw.services.icd.db.IcdDb$.$anonfun$run$5(IcdDb.scala:129)
    at csw.services.icd.db.IcdDb$.$anonfun$run$5$adapted(IcdDb.scala:129)
    at scala.Option.foreach(Option.scala:257)
    at csw.services.icd.db.IcdDb$.run(IcdDb.scala:129)
    at csw.services.icd.db.IcdDb$.delayedEndpoint$csw$services$icd$db$IcdDb$1(IcdDb.scala:107)
    at csw.services.icd.db.IcdDb$delayedInit$body.apply(IcdDb.scala:21)
    at scala.Function0.apply$mcV$sp(Function0.scala:34)
    at scala.Function0.apply$mcV$sp$(Function0.scala:34)
    at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:12)
    at scala.App.$anonfun$main$1$adapted(App.scala:76)
    at scala.collection.immutable.List.foreach(List.scala:389)
    at scala.App.main(App.scala:76)
    at scala.App.main$(App.scala:74)
    at csw.services.icd.db.IcdDb$.main(IcdDb.scala:21)
    at csw.services.icd.db.IcdDb.main(IcdDb.scala)
Build step 'Execute shell' marked build as failure

So, it would be nice to have something like a -y option that just answers yes to everything in an automated setting.

edwardchapin commented 6 years ago

Never mind, I can just do:

yes | icd-db ...