Coder Social home page Coder Social logo

boogrocha's Introduction

Go Report Card Build Status boogrocha

BooGroCha

A CLI client for chalmers' group room booking system.

Features

  • Book group rooms
  • Integration Chalmers booking system
  • Save personal settings in config file
  • List available bookings for selected time
  • Delete bookings
  • List bookings
  • Relative times for bookings
  • AUR package
  • Rooms sorted base on user preferences
  • Option to only show rooms from preferred campus
  • Integrate with Chalmers Library booking system
  • Book rooms in the Johanneberg Student Union building
  • Prompt for password if not set

Installation

Compile from source

Requirements

  • go (>= 1.12)
  • $GOPATH/bin in $PATH

Steps

$ git clone https://github.com/williamleven/BooGroCha
$ cd BooGroCha/cmd/bgc
$ go install

Usage

Book a room

Allows for booking rooms by showing the available rooms for the given date and time.

$ bgc book <date> <time>
  • <date> can be either an absolute date (YYYYMMDD, YYMMDD) or a relative date (MMDD, DD, D, today, tomorrow, monday, tuesday ...)
  • <time> can be either (HH:mm-HH:mm, HH-HH, H-H, H-HH, HH-H) or aliases like lunch

The book sub-command also takes the following optional flags:

  • --cid <cid> to perform the book request with a specified cid
  • --campus <campus> or -c <campus> to filter the available rooms by a specified campus. (Valid campuses are J, Johanneberg, L and Lindholmen. Note that these values are not case-sensitive)
  • --size <size> or -s <size> to filter the available rooms by size and will only show the rooms that are big enough. (When a size is specified the list of available rooms will also show the capacity of each room)
  • --room <room> or -r <room> to try to book a specified room (the name of the room is case-insensitive) instead of letting you choose one interactively from the list of available rooms.
  • --message <message> or -m <message> to add a specific message to the booking instead of asking for it interactively.

List booked rooms

$ bgc list

Delete booked rooms

$ bgc delete

Configuration

Allows the user to set parameters in a config file.

Setting a variable

$ bgc config set <variable> <value>
  • <variable> can for example be cid or pass
  • <value> should be the value that you want to set the variable to (NOTE: when setting the password you will be prompted for input instead of setting it directly)

Clearing a variable

$ bgc config clear <variable>
  • <variable> can for example be cid or pass

Showing a variable

$ bgc config get <variable>
  • <variable> can for example be cid or campus (NOTE: You cannot show the pass variable this way)

boogrocha's People

Contributors

herrnan avatar williamleven avatar jbleduigou avatar hulthe avatar

Stargazers

 avatar  avatar  avatar  avatar Simon Sundström avatar

Watchers

James Cloos avatar  avatar

boogrocha's Issues

Building from AUR still doesn't work

==> Starting pkgver()...
/home/nan/.cache/yay/boogrocha/PKGBUILD: line 16: cd: /home/nan/.cache/yay/boogrocha/src/boogrocha-r46.b1d7201: No such file or directory
==> ERROR: pkgver is not allowed to be empty.
==> ERROR: pkgver() generated an invalid version: 

Fails to parse bookings

create one booking and try to list bookings

panic: parsing failure

goroutine 1 [running]:
sidus.io/boogrocha/internal/cli/commands.runList(0xc00015a500, 0xd81f48, 0x0, 0x0, 0x960f60)
        /home/gurgy/.cache/yay/boogrocha/src/boogrocha-r43.6342c69/internal/cli/commands/list.go:30 +0x6d7
sidus.io/boogrocha/internal/cli/commands.ListCmd.func1(0xc00015a500, 0xd81f48, 0x0, 0x0)
        /home/gurgy/.cache/yay/boogrocha/src/boogrocha-r43.6342c69/internal/cli/commands/list.go:18 +0x52
github.com/spf13/cobra.(*Command).execute(0xc00015a500, 0xd81f48, 0x0, 0x0, 0xc00015a500, 0xd81f48)
        /home/gurgy/go/pkg/mod/github.com/spf13/[email protected]/command.go:766 +0x2ae
github.com/spf13/cobra.(*Command).ExecuteC(0xd5c760, 0x847ea3, 0xc000131f88, 0xc000096058)
        /home/gurgy/go/pkg/mod/github.com/spf13/[email protected]/command.go:850 +0x2fc
github.com/spf13/cobra.(*Command).Execute(...)
        /home/gurgy/go/pkg/mod/github.com/spf13/[email protected]/command.go:800
main.main()
        /home/gurgy/.cache/yay/boogrocha/src/boogrocha-r43.6342c69/cmd/bgc/main.go:9 +0x2e

Booking for student union building rooms uses wrong url

At the moment of writing this TimeEdit for Chalmers uses two different versions for booking regular group rooms and rooms in the student union building, chalmers_test and chalmers respectivly. However, the current implementation uses only chalmers_test. This causes a problem since even though we cannot see the possibility to book student union rooms on chalmers_test` in the web browser the api still allows it. This allows for two bookings identical bookings one on each version which could lead to a lot of confusion.

Web API

All endpoints return errors along with other response data specified below

error
{
    code: int
    error: string
    message: string
}
  • POST /api/auth/login
{
  chalmers: {
    cid: string
    password: string
  }
}

validate the credentials
encrypt them,
send them back as cookie

set cookie
{
  errors: [error]
}
  • POST /api/auth/logout
cookie
unset cookie
{
 errors: [error]
}
  • GET /api/booking/availible?from=2016-11-03T12:15&to=2016-11-03T12:30
cookie
{
  rooms: [{
    provider: string
    id: string
  },...]
  errors: [error]
}
  • GET /api/booking
cookie
{
  bookings: [{
    id: string
    from: string (2016-11-03T12:15)
    to: string (2016-11-03T12:30)
    room: {
      provider: string
      id: string
    }
  },...]
  errors: [error]
}
  • DELETE /api/booking/{id}
cookie
{
 errors: [error]
}
  • POST /api/booking
cookie
{
  from: string (2016-11-03T12:15)
  to: string (2016-11-03T12:30)
  text: string
  room: {
    provider: string
    id: string
  }
}
{
  id: string
  errors: [error]
}

Rooms sorted base on user preferences

It would be nice to have the list of available rooms sorted after my personal preferences so that the ones I am more likely to book appear with a lower number.

Crash when running "bgc book"

When I ran bgc book without any other information I received an index out of bounds exception. Full log:

panic: runtime error: index out of range

goroutine 1 [running]:
sidus.io/boogrocha/internal/cli/commands.readArgs(0xd81f48, 0x0, 0x0, 0x0, 0x2, 0xd66160, 0x7fb8ad5c6d98, 0x0, 0x40000c0000a9818)
        /home/vidde/.cache/yay/boogrocha/src/boogrocha/internal/cli/commands/book.go:106 +0x291
sidus.io/boogrocha/internal/cli/commands.run(0xc0000d5900, 0xd81f48, 0x0, 0x0, 0x960f78, 0x960f80)
        /home/vidde/.cache/yay/boogrocha/src/boogrocha/internal/cli/commands/book.go:35 +0x83
sidus.io/boogrocha/internal/cli/commands.BookCmd.func1(0xc0000d5900, 0xd81f48, 0x0, 0x0)
        /home/vidde/.cache/yay/boogrocha/src/boogrocha/internal/cli/commands/book.go:21 +0x5b
github.com/spf13/cobra.(*Command).execute(0xc0000d5900, 0xd81f48, 0x0, 0x0, 0xc0000d5900, 0xd81f48)
        /home/vidde/go/pkg/mod/github.com/spf13/[email protected]/command.go:766 +0x2ae
github.com/spf13/cobra.(*Command).ExecuteC(0xd5c760, 0x848683, 0xc000133f88, 0xc000092058)
        /home/vidde/go/pkg/mod/github.com/spf13/[email protected]/command.go:850 +0x2fc
github.com/spf13/cobra.(*Command).Execute(...)
        /home/vidde/go/pkg/mod/github.com/spf13/[email protected]/command.go:800
main.main()
        /home/vidde/.cache/yay/boogrocha/src/boogrocha/cmd/bgc/main.go:9 +0x2e

Error when trying to set an empty password

$ bgc config set pass
> Enter Password (default: ""):
> Failed to save password: invalid argument

Simply pressing enter when the CLI asks for your password returns an error, even though it claims to default to an empty string.

Cache room list

Currently the room list is fetched each time the command is invoked and rarely changes. Would be nice to cache the list to speed up response times and reduce load on chalmers servers

Integrate with Chalmers Library booking system

I would also like to be able to book the group rooms in the Chalmers Library with the program. At the moment those rooms are handled by a separate system and are therefore not included by default.

Add readme file

We need a readme file that explains how to develop on, run and use the tool.

Error while trying to log in

The following error occured when I ran bgc book.

panic: assignment to entry in nil map

goroutine 1 [running]:
net/url.Values.Add(...)
	/usr/lib/go/src/net/url/url.go:852
sidus.io/boogrocha/internal/booking/chalmers.NewBookingService(0xc00002a886, 0x6, 0xc000026560, 0x20, 0x6, 0x8, 0x8, 0xc000115b30, 0x203000, 0x8a3760)
	/home/hulthe/.cache/yay/boogrocha/src/boogrocha/internal/booking/chalmers/bookingService.go:214 +0x1e9
sidus.io/boogrocha/internal/cli.getBookingService(0xc000115b98, 0x10)
	/home/hulthe/.cache/yay/boogrocha/src/boogrocha/internal/cli/bookingService.go:16 +0xdc
sidus.io/boogrocha/internal/cli/commands.run(0xc0000b1b80, 0xc00000e8e0, 0x2, 0x2, 0x980520, 0x980528)
	/home/hulthe/.cache/yay/boogrocha/src/boogrocha/internal/cli/commands/book.go:33 +0x3f
sidus.io/boogrocha/internal/cli/commands.BookCmd.func1(0xc0000b1b80, 0xc00000e8e0, 0x2, 0x2)
	/home/hulthe/.cache/yay/boogrocha/src/boogrocha/internal/cli/commands/book.go:21 +0x5b
github.com/spf13/cobra.(*Command).execute(0xc0000b1b80, 0xc00000e8a0, 0x2, 0x2, 0xc0000b1b80, 0xc00000e8a0)
	/home/hulthe/go/pkg/mod/github.com/spf13/[email protected]/command.go:766 +0x2aa
github.com/spf13/cobra.(*Command).ExecuteC(0xd53240, 0x0, 0x54e00, 0xc00002e118)
	/home/hulthe/go/pkg/mod/github.com/spf13/[email protected]/command.go:850 +0x2fb
github.com/spf13/cobra.(*Command).Execute(...)
	/home/hulthe/go/pkg/mod/github.com/spf13/[email protected]/command.go:800
main.main()
	/home/hulthe/.cache/yay/boogrocha/src/boogrocha/cmd/bgc/main.go:9 +0x2d

It appears to have something to do with auth since from what I can gather, the response from the login request doesn't look as expected, and this value is set to nil.

Prompt for password if one isn't set

I don't wan to save my password in a file on the system but like to use the program. A solution would be to prompt the user for the password when it's needed in the absence of one in the config file.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.