From a4e2eb65e84e34eba185fb75028018d9dd61c809 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Tue, 17 Oct 2023 15:34:12 -0700 Subject: [PATCH] read data from commandline arg --- 0013-Data | 1 + 0014-on.initialize | 6 +++++- 0019-on.code_change | 4 +++- 0021-Results_filename | 2 ++ 0022-absolutize | 6 ++++++ results | 1 + 6 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 0021-Results_filename create mode 100644 0022-absolutize diff --git a/0013-Data b/0013-Data index 85c9284..0dd1c2d 100644 --- a/0013-Data +++ b/0013-Data @@ -1,4 +1,5 @@ Data = { + -- example standings during the 2023 Cricket World Cup Ind={Pak=2, Aus=2}, NZ={Eng=2}, SA={Aus=2, SL=2}, diff --git a/0014-on.initialize b/0014-on.initialize index 2c33837..cfb545e 100644 --- a/0014-on.initialize +++ b/0014-on.initialize @@ -1,3 +1,7 @@ on.initialize = function(arg) + if #arg > 0 then + Results_filename = absolutize(arg[1]) + Data = load_results(Results_filename) + end Rows = ordered_keys(Data) -end +end \ No newline at end of file diff --git a/0019-on.code_change b/0019-on.code_change index dd39edb..579449b 100644 --- a/0019-on.code_change +++ b/0019-on.code_change @@ -1,4 +1,6 @@ on.code_change = function() - Data = load_results(App.current_dir..'results') + if Results_filename then + Data = load_results(Results_filename) + end Rows = ordered_keys(Data) end \ No newline at end of file diff --git a/0021-Results_filename b/0021-Results_filename new file mode 100644 index 0000000..3172f6b --- /dev/null +++ b/0021-Results_filename @@ -0,0 +1,2 @@ +-- Filename to maintain results in +Results_filename = nil \ No newline at end of file diff --git a/0022-absolutize b/0022-absolutize new file mode 100644 index 0000000..0ea3e4d --- /dev/null +++ b/0022-absolutize @@ -0,0 +1,6 @@ +absolutize = function(path) + if is_relative_path(path) then + return App.current_dir..path + end + return path +end \ No newline at end of file diff --git a/results b/results index 0c4dfda..c650b07 100644 --- a/results +++ b/results @@ -11,3 +11,4 @@ NZ beat Ban Ind beat Pak Afg beat Eng Aus beat SL +Ned beat SA