;
; Install script for scion datatype
;

(set #datatype      (cat "scion.datatype"))
(set #datatype-desc (cat "Scion"))

(set mode
     (askchoice
         (prompt @app-name)
         (help @askchoice-help)
         (choices "Install" "Remove")
     )
)

(if mode
        (set pmode "Remove")
        (set pmode "Install")
)

; Get the classes dir
(set classdir
        (askdir
                (prompt "Where do the Classes belong")
                (help @askdir-help)
                (default "SYS:Classes")
        )
)

; Now install or remove
(if mode
        ; Remove
        (
                ; Show what we are doing
                (working "Removing " @app-name)

                ; Remove the non-standard pieces
                (delete (tackon classdir "datatypes" #datatype))
                (delete (cat "devs:datatypes/" #datatype-desc) (infos))

                ; Don't want to use the confusing "Installation Complete" message
                ; when what we really did was remove things...
                (message "The \"" @app-name "\" components "
                         "that you specified have been successfully removed")
                (exit (quiet))
        )

        ; Install
        (
                (working "Installing " @app-name)

                ; Install the classes
                (copylib
                        (prompt (cat "Copying " @app-name))
                        (help @copylib-help)
                        (source #datatype)
                        (dest (tackon classdir "DataTypes"))
                        (confirm)
                )

                ; Install the descriptors
                (copyfiles
                        (prompt "Copying the Descriptors")
                        (help @copyfiles-help)
                        (source #datatype-desc)
                        (dest "DEVS:DataTypes")
                        (infos)
			(confirm)
                )

                ; Install documentation
                (copyfiles
                        (prompt "Copying documentation")
                        (help @copyfiles-help)
                        (source "ReadMe")
                        (dest "Work:")
                        (confirm)
                )

                ; Tell the system about the new descriptors
                (run "C:AddDataTypes Refresh")

        )
)

(set @default-dest classdir)

