From 5ca487daa2182f9ff6aa40b1a05dc3db6d0fc84f Mon Sep 17 00:00:00 2001 From: Jeffrey Armstrong Date: Wed, 24 Mar 2021 16:41:09 -0400 Subject: Added concept of player identity. Started on the instructions processing loop. --- player/main.F90 | 109 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100644 player/main.F90 (limited to 'player/main.F90') diff --git a/player/main.F90 b/player/main.F90 new file mode 100644 index 0000000..127a8f7 --- /dev/null +++ b/player/main.F90 @@ -0,0 +1,109 @@ +program player +use config +implicit none + + character(len=1024)::option + + integer::slen + integer::i + + identity = " " + + i = 1 + do while(i <= command_argument_count()) + call get_command_argument(i, option) + + if(option(1:1) /= "-") then + captain = option + + else if(trim(option) == "-h") then + call usage() + stop + + else if(trim(option) == "-w") then + i = i + 1 + call get_command_argument(i, length=slen) + allocate(character(len=slen) :: working_directory) + call get_command_argument(i, working_directory) + + else if(trim(option) == "-l") then + i = i + 1 + call get_command_argument(i, length=slen) + allocate(character(len=slen) :: logfile) + call get_command_argument(i, logfile) + + else if(trim(option) == "-i") then + i = i + 1 + call get_command_argument(i, identity) + + end if + + i = i + 1 + end do + + ! Assign working directory from command if not specified + if(.not. associated(working_directory)) then + call get_command_argument(0, length=slen) + allocate(character(len=slen) :: working_directory) + call get_command_argument(i, working_directory) + i = index(working_directory, "/", back=.true.) + if(i == 0) then + i = index(working_directory, "/", back=.true.) + endif + if(i == 0) then + Print *, "Could not determine working_directory" + stop + else + working_directory(i:slen) = ' ' + end if + end if + + ! Assign a temporary directory and file for a log file + ! NOTE: will fail on Windows + if(.not. associated(logfile)) then + allocate(character(len=256) :: logfile) + logfile = "/tmp/levitating.log" + end if + + ! Assign this computer an identity if not explicitly specified + if(len_trim(identity) == 0) then +#ifdef GNU + call hostnm(identity) +#else + Print *, "Could not determine host identity" + stop +#endif + end if + + ! Change directory to the working directory now + call chdir(working_directory) + + do while(.true.) + + + + end do + +contains + + subroutine usage() + implicit none + + character(len=256)::pname + + call get_command_argument(0, pname) + + Print *, "Usage: "//trim(pname)//" " + Print *, " " + Print *, "captain is the build control server" + Print *, " " + + Print *, "Options:" + Print *, " -h Display this help" + Print *, " -w Use dir as the working directory" + Print *, " -l Use log as the logfile" + Print *, " -i This players identity" + + end subroutine usage + +end program player \ No newline at end of file -- cgit v1.2.3