https://github.com/al3rez/parking-lot
Parking lot - Gojek :car:
https://github.com/al3rez/parking-lot
Last synced: about 1 month ago
JSON representation
Parking lot - Gojek :car:
- Host: GitHub
- URL: https://github.com/al3rez/parking-lot
- Owner: al3rez
- Created: 2019-08-30T05:33:21.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2019-09-03T01:49:07.000Z (over 6 years ago)
- Last Synced: 2025-10-09T10:39:19.682Z (8 months ago)
- Language: Go
- Homepage:
- Size: 29.3 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# parking-lot [](https://travis-ci.com/azbshiri/parking-lot) [](https://codebeat.co/a/alireza-bashiri/projects/github-com-azbshiri-parking-lot)
This is a solution for Gojek parking lot test

# Installation
To build this locally you should either have [Go](https://docs.docker.com/install/) or [Docker](https://golang.org/doc/install) installed.
```shell script
$ cd parking-lot
$ go install
$ parking-lot -h
Usage of parking-lot:
-f string
Execute parking lot instructions from given file
-i Execute parking lot instructions from interactive shell
```
### Building `parking-lot` binary inside a Docker container:
```shell script
$ cd parking-lot
$ docker build -t parking-lot
$ docker run -ti parking-lot -h
Usage of parking-lot:
-f string
Execute parking lot instructions from given file
-i Execute parking lot instructions from interactive shell
```
# CLI Usage
```shell script
Usage of parking-lot:
-f string
Execute parking lot instructions from given file
-i Execute parking lot instructions from interactive shell
-stdin
Execute parking lot instructions from standard streams
````
### Read instructions from a file (locally)
```shell script
$ parking-lot -f file_inputs.txt
Created a parking lot with 6 slots
Allocated slot number: 1
Allocated slot number: 2
Allocated slot number: 3
Allocated slot number: 5
Allocated slot number: 5
Allocated slot number: 6
...
```
### Read instructions from a file (it's actually standard stream) (Docker)
```shell script
$ cat file_inputs.txt | docker run -i parking-lot -i -stdin
created a parking lot with 6 slots
allocated slot number: 1
allocated slot number: 2
allocated slot number: 3
allocated slot number: 5
allocated slot number: 5
allocated slot number: 6
...
```
```shell script
$ cat file_inputs.txt | parking-lot -i -stdin
created a parking lot with 6 slots
allocated slot number: 1
allocated slot number: 2
allocated slot number: 3
allocated slot number: 5
allocated slot number: 5
allocated slot number: 6
...
```
### Read instructions from interactive shell (locally/Docker)
```shell script
$ docker run -ti parking-lot -i
parking-lot> create_parking_lot 6
Created a parking lot with 6 slots
parking-lot> park KA-01-HH-1234 White
...
```
```shell script
$ parking-lot -i
parking-lot> create_parking_lot 6
Created a parking lot with 6 slots
parking-lot> park KA-01-HH-1234 White
Allocated slot number: 1
parking-lot> park KA-01-HH-1234 White
Allocated slot number: 2
...
```
# Running tests
```shell script
$ cd parking-lot
$ go test -v ./...
````
# TODO
- [ ] Abstract out error handling in cli.Context