Intercom Party invitation system
This tool is designed to be ran on the CLI. It accepts the customer list as a standard input, and will return the results on the standard out. The parameters for running can be set using flags.
- Go 1.16+
To compile a binary version of the application, run
go build ./cmd/party
The one line command to filter customers 100km from the Dublin office (default flags) is:
cat customers.txt | party | tee output.txt
The defaults can howeverbe changed by the following flags:
Name | Default | Description |
---|---|---|
-office |
Dublin |
Office to be used to host the party. Currently only Dublin is available, but more can be added in internal/office/office.go . In the future this can be replaced by office inventory system or some dynamic API call. |
-distance |
100km |
Human readable format for writing the maximum distance. This is in a format of Xkm , XkmYm , Ym , where X and Y are numbers. |
All tests can be ran by the following command
go test ./...
This is where the binary lives. It contains the flag parsing, handing stdin and stdout. All components are integrated in there. The flow it follows is as follows
- Parse Flags
- Get office
- Parse maximum distance
- Get customers from stdin
- Filter customers if they are within the radius of the office
- Sort customers by ID
- Output the new customer list to the stdout
Customer package contains parsing functionality for the customer file, sorting functions, filtering the customers and finally writing to file.
The distance package contains human readable distance parsing and calculation of distance between 2 coordinates.
Office contains the office coordinates for a list of available offices. It is currently only Dublin, but more can be added if needed.