Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
TodePond committed Sep 4, 2022
2 parents e2681c2 + 15020f9 commit 37fb07a
Show file tree
Hide file tree
Showing 6 changed files with 140 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ If you export a function called `main`...<br>
An extra `-standalone.js` file will appear, that you can run in the command line with [deno](https://deno.land).<br>

## What? I don't understand?
Check out the [Hello World Guide](docs/hello-world-long.md).
Check out the [Hello World Guide](docs/hello-world.md).

## Anything else I should know?
Yes! There are some limitations! But it's all a secret (for now).
50 changes: 50 additions & 0 deletions docs/arguments.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Arguments Guide
Standalone frogasaurus libraries can take arguments.<br>

## Single Argument
Let's make a library that says hello to a given name.

#### `Greeter/source/greet.js`
```js
export const main = (name) => {
console.log(`Hello ${name}!`)
}
```

Then, let's build it by using the usual command.
```
frogasaurus
```

Our library is built! Let's install it to our command line!
```
deno install --name greet greeter-standalone.js
```

Now, we can use our library with arguments in the command line to say hello to different people.

This prints "Hello Lu!"
```
greet Lu
```

This prints "Hello world!"
```
greet world
```

## Multiple Arguments
Multiple arguments work the same way.<br>
Let's make a library that adds two numbers together

#### `Adder/source/add.js`
```js
export const main = (a, b) => {
return parseInt(a) + parseInt(b)
}
```

After following the same steps to install it, we can do something like this:
```
add 3 2
```
5 changes: 5 additions & 0 deletions docs/guides.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Frogasaurus Guides
Here are some guides on how to use Frogasaurus:
* [Hello World Guide (**long** version)](hello-world-long.md)
* [Hello World Guide (**short** version)](hello-world-short.md)
* [Arguments Guide](arguments.md)
19 changes: 11 additions & 8 deletions docs/hello-world-long.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Hello World Guide (long version)
This is a long-winded guide on how to make your first library with Frogasaurus!<br>
A shorter version is *coming soon-ish*.
A shorter version is available [here](hello-world-short.md).

## Installing
Before you start, you might need to install [deno](https://deno.land) (if you haven't already).
Expand Down Expand Up @@ -45,8 +45,8 @@ frogasaurus
```

After doing that, you should notice that two files have appeared in your folder!
* `Hello/source/hello-embed.js`
* `Hello/source/hello-import.js`
* `Hello/hello-embed.js`
* `Hello/hello-import.js`

Each file is a different version of your library.<br>
Each version can be used in a different way.<br>
Expand All @@ -71,7 +71,7 @@ To use the `import` version... import it like this:

#### `Hello/script.js`
```js
import { hello } from "./Hello-import.js`
import { hello } from "./hello-import.js`
hello()
```
Expand All @@ -80,16 +80,15 @@ You could run `script.js` with this command:
deno run script.js
```
## Using the library (module)
Alternatively, you could use the `import` file as a javascript module:
Or you could use the library from within a module:
#### `Hello/index.html`
```html
<script type="module" src="hello-import.js"></script>
<script type="module">
import { hello } from "./hello-import.js"
hello()
</script>
```
Expand Down Expand Up @@ -134,3 +133,7 @@ This lets you use your library from the command line:
```
hello
```
## Now what?
I don't know! It's up to you.<br>
Want to check out the full list of [guides](guides.md)?
69 changes: 69 additions & 0 deletions docs/hello-world-short.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Hello World Guide (short version)
This is a short guide on how to make your first library with Frogasaurus!<br>
A longer version is available [here](hello-world-long.md).

## Installing
Install Frogasaurus with [deno](https://deno.land) using this command:
```
deno install --allow-write=. --allow-read=. https://deno.land/x/frogasaurus/frogasaurus.js
```

## Writing the code
Write all your code in a folder named `source`.<br>

#### `Hello/source/hello.js`
```js
export const hello = () => {
console.log("Hello world!")
}
```

## Building the library
Run this command in the project root folder.
```
frogasaurus
```

## Using the library
Frogasaurus builds two files
* `Hello/hello-embed.js`
* `Hello/hello-import.js`

Use the `embed` version like this:
#### `Hello/index.html`
```html
<script src="hello-embed.js"></script>
<script>
const { hello } = Hello
hello()
</script>
```

Use the `import` version like this:
#### `Hello/script.js`
```js
import { hello } from "./hello-import.js"
hello()
```

## Standalone
If you export a function called `main`, an extra file gets built:<br>
* `Hello/hello-standalone.js`

You can run the `main` function by running the file:<br>
```
deno run hello-standalone.js
```

Or... you could install it:<br>
```
deno install --name hello hello-standalone.js
```

Then, you can call the `main` function from the command line:
```
hello
```

## Now what?
Maybe... explore more [guides](guides.md)?
4 changes: 4 additions & 0 deletions docs/hello-world.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Hello World Guide
Which version of the guide would you like to see?
* [**long** version](hello-world-long.md)
* [**short** version](hello-world-short.md)

0 comments on commit 37fb07a

Please sign in to comment.