-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/l2wilson94/Frogasaurus
- Loading branch information
Showing
6 changed files
with
140 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |