aboutsummaryrefslogtreecommitdiff
path: root/player/main.f90
diff options
context:
space:
mode:
authorJeffrey Armstrong <jeff@approximatrix.com>2021-03-24 14:58:32 -0400
committerJeffrey Armstrong <jeff@approximatrix.com>2021-03-24 14:58:32 -0400
commitfb11ffeb2d98f239b20e618c65b8534b677957e9 (patch)
treeccb017781f08d10b8d5f5cd6569122b84af997a5 /player/main.f90
downloadlevitating-fb11ffeb2d98f239b20e618c65b8534b677957e9.tar.gz
levitating-fb11ffeb2d98f239b20e618c65b8534b677957e9.zip
Initial import
Diffstat (limited to 'player/main.f90')
-rw-r--r--player/main.f9087
1 files changed, 87 insertions, 0 deletions
diff --git a/player/main.f90 b/player/main.f90
new file mode 100644
index 0000000..cdf646e
--- /dev/null
+++ b/player/main.f90
@@ -0,0 +1,87 @@
+program player
+use config
+implicit none
+
+ character(len=1024)::option
+
+ integer::slen
+ integer::i
+
+ 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)
+
+ 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
+
+ ! Change directory to the working directory now
+ call chdir(working_directory)
+
+
+contains
+
+ subroutine usage()
+ implicit none
+
+ character(len=256)::pname
+
+ call get_command_argument(0, pname)
+
+ Print *, "Usage: "//trim(pname)//" <options> <captain>"
+ Print *, " "
+ Print *, "captain is the build control server"
+ Print *, " "
+
+ Print *, "Options:"
+ Print *, " -h Display this help"
+ Print *, " -w <dir> Use dir as the working directory"
+ Print *, " -l <log> Use log as the logfile"
+
+ end subroutine usage
+
+end program player \ No newline at end of file