Skip to content

Commit b8c4c74

Browse files
feat: readme cleanup (#28)
1 parent 06f228e commit b8c4c74

File tree

1 file changed

+23
-28
lines changed

1 file changed

+23
-28
lines changed

README.MD

Lines changed: 23 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -39,31 +39,38 @@ etc, etc, etc.
3939
All flights are defined in `extension/flights.ts`.
4040

4141
## Logical Flights
42-
Logical flights are, I guess you could call, "smart links".
43-
They arent hardcoded into this repository and use logic to determine where you want to go.
44-
You can set defaults for anything within a logical flight.
42+
Logical flights are smarter than a standard flight because you can set defaults for any variable of the flight.
4543

44+
Defaults can be set/unset via:
45+
- `fly set {key} {value}`
46+
- `fly unset {key}`
47+
48+
### How it works
4649
Look at the `gh` logical flight as an example. Its logic is as follows: `https://github.com/${gh-org}/${repo}`.
4750

4851
If no defaults are specified, the extension will assume you will pass in at least 2 parameters to the flight.
49-
`fly hg Apollorion manifests.io` is calculated positionally in this case. `Apollorion` will replace `${gh-org}` and `manifests.io` will replace `${repo}`.
52+
`fly gh Apollorion manifests.io` is calculated positionally. `Apollorion` (the first parameter) will replace `${gh-org}` (the first variable)
53+
and `manifests.io` (the second parameter) will replace `${repo}` (the second variable).
5054
Which will fly to `https://github.com/Apollorion/manifests.io`.
5155

52-
You can, optionally, set a default for any parameter in a logical flight.
53-
`fly set gh-org Apollorion` will set the default for `gh-org` to `Apollorion`.
54-
Now, when you fly the `gh` flight, it will first replace `${gh-org}` with `Apollorion` and then any remaining parameters will be replaced positionally.
56+
You can, optionally, set a default for any variable in a logical flight.
57+
`fly set gh-org Apollorion` will set the default for `gh-org` to `Apollorion`.
58+
Now, when you fly the `gh` flight, it will first replace `${gh-org}` with `Apollorion` and then any remaining parameters will be replaced positionally, like above.
5559
So you could do `fly gh manifests.io` and it will fly to `https://github.com/Apollorion/manifests.io`.
5660

5761
Note: ANY unset parameters will be replaced positionally, in order.
5862
If you have a logical flight that is defined as `https://my.com/{$thing1}/{$thing2}/{$thing3}`, and you only set the default for `thing1`.
59-
The extension will expect you to pass in 2 parameters at flight time, otherwise a default flight will be used or an error will be thrown.
63+
The extension will expect you to pass in 2 parameters at flight time, otherwise a default flight will be used or an error will be thrown.
6064
`fly my.com test1 test2` will fly to `https://my.com/{thing1 default}/test1/test2/`.
6165
`fly my.com test` will either go to a defined default flight or throw an error.
6266

6367
# Custom flight repos
6468
You can host a custom flight repo and point the extension to it. This will allow you to define standard and logical flights without contributing to this project.
6569

66-
An example repo doc is here: `https://apollorion.com/flight_repo_named.json`
70+
Repos can be managed via:
71+
- `fly repo set {name} {url}`
72+
- `fly repo unset {name}`
73+
- `fly repo update` - this is what actually fetch's flight data. Akin to `apt update`.
6774

6875
The custom flight repo has 2 requirements.
6976
1. The `Access-Control-Allow-Origin: *` header is present (this is a chrome requirement)
@@ -82,34 +89,22 @@ interface CustomFlightRepo {
8289
}
8390
}
8491
```
85-
86-
To use the custom flight repo, just run `fly repo set $name $url` then `fly repo update`. You can unset this repo at anytime via `fly repo unset $name`.
87-
`fly repo update` will fetch the contents of the repository.
92+
An example repo doc is here: `https://apollorion.com/flight_repo_named.json`
8893

8994
ex:
9095
1. `fly repo set apollorion https://apollorion.com/flight_repo_named.json`
9196
2. `fly repo update`
97+
3. `fly repo unset apollorion`
98+
99+
Note: Logical flights take precedence over standard flights, in a custom flight repo. If a flight is defined in this extension as a logical flight, and you want to simplify it, you will want to
100+
define it as a logical flight in your repo. Otherwise, your flight will not work.
92101

93102
# Devving this repo
94103

95104
Startup the dev server via `./dev.sh`.
96105
You need to `load unpacked` the extension in the `extension/dist` dir after building at least once.
97106

98-
I havent found a work around yet, but whenever you make a change you need to refresh the extension in `chrome://extensions`.
99-
100-
101-
## Logical Flights
102-
Say a users query is `fly gh Apollorion manifests.io`
103-
104-
The example logic above will match `gh`, split `Apollorion manifests.io` into `$1` = `Apollorion` and `$2` = `manifests.io`.
105-
The logic defined in `extension/flights.ts` for `gh` is `https://github.com/$1/$2` which resolves to `https://github.com/Apollorion/manifests.io`.
106-
107-
If your logical flight doesnt need to be very smart you can simply add the flight name (`gh` in the above example) to the`logicalFlights` const in `extension/main.ts`.
108-
The extension will "just work" if you expect users to always type the full query in the extension.
109-
As an example, the `aws` flight automatically builds the correct query without any special logic because it expects the user to type the full query every time.
110-
111-
If you logical flight does need some custom logic, you can build that into `extension/main.ts`. I'd suggest using `gh` as an example.
112-
107+
I haven't found a work around yet, but whenever you make a change you need to refresh the extension in `chrome://extensions`.
113108

114109
# Alfred
115-
If youre looking for the alfred implementation of fly, checkout https://github.com/Apollorion/fly-alfred
110+
If you're looking for the alfred implementation of fly, checkout https://github.com/Apollorion/fly-alfred (depreciated).

0 commit comments

Comments
 (0)