diff --git a/addrbook.rex b/addrbook.rex index 73505d8..3ce06c9 100755 --- a/addrbook.rex +++ b/addrbook.rex @@ -9,8 +9,10 @@ * Frontend: Object Rexx with ncurses extensions. * **************************************************************************/ signal on HALT name ProgramHalt +signal on ERROR name ProgramError +.environment~home = SysGetpwuid(SysGetuid(), "d") .environment['STOPNOW'] = 0 -rc = setEnv("./config.json") +rc = setEnv(.nil) if rc \= 0 then do say "Configuration failed." exit rc @@ -29,6 +31,7 @@ Do forever end Exit +signal on ERROR name ProgramError ::CLASS AddressBookApp PUBLIC @@ -102,6 +105,12 @@ return 0 return rc +ProgramError: + say 'An error has occurred' + say rc + say signal +Exit rc + /** External Libraries **/ ::requires 'appdb.cls' ::requires 'appui.cls' diff --git a/app/appdb.cls b/app/appdb.cls index 3a5bf69..4d36579 100644 --- a/app/appdb.cls +++ b/app/appdb.cls @@ -1,7 +1,7 @@ ::requires 'ooSQLite.cls' ::requires "rxunixsys" LIBRARY ::requires 'ncurses.cls' -::requires 'app/utils.rex' +::requires 'utils.rex' ::CLASS AddressBookDB PUBLIC diff --git a/app/appui.cls b/app/appui.cls index ed90be9..df5e733 100644 --- a/app/appui.cls +++ b/app/appui.cls @@ -1,7 +1,7 @@ ::requires 'ooSQLite.cls' ::requires "rxunixsys" LIBRARY ::requires 'ncurses.cls' -::requires 'app/utils.rex' +::requires 'utils.rex' ::class AddressBookUI public diff --git a/config.json b/config.json deleted file mode 100644 index 63910f8..0000000 --- a/config.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "dbFile":"/home/gmgauthier/Projects/rexx-address-book/db/contacts.sqlite" -} diff --git a/default-config.json b/default-config.json new file mode 100644 index 0000000..9ea6b40 --- /dev/null +++ b/default-config.json @@ -0,0 +1,3 @@ +{ + "dbFile":"/home/{your-user-id}/.local/share/rexx-address-book/contacts.sqlite" +} \ No newline at end of file diff --git a/install.rex b/install.rex new file mode 100755 index 0000000..027c989 --- /dev/null +++ b/install.rex @@ -0,0 +1,18 @@ +#!/usr/bin/env rexx +/*************************************************** + * Installer for the Rexx Address Book * + ***************************************************/ + +Say "Setting up directories..." +Address system "mkdir -p ~/.local/bin && mkdir -p ~/.config/rexx-address-book && mkdir -p ~/.local/share/rexx-address-book" + +Say "Setting up default config file..." +Address system "cp ./default-config.json ~/.config/rexx-address-book/config.json" + +Say "Copying application scripts..." +Address system "cp app/*.cls ~/.local/bin && cp app/utils.rex ~/.local/bin" +Address system "cp ./addrbook.rex ~/.local/bin/addrbook && chmod +x ~/.local/bin/addrbook" + +Say "Installation complete." + +EXIT