Skip to content

Commit

Permalink
repl exit message prettified
Browse files Browse the repository at this point in the history
  • Loading branch information
tacheraSasi committed Nov 28, 2024
1 parent 1bdd4e1 commit e126c82
Show file tree
Hide file tree
Showing 5 changed files with 168 additions and 31 deletions.
10 changes: 3 additions & 7 deletions repl/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ func (pg playground) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
if pg.language == "en" {
pg.editor.Placeholder = "Write vint code here..."
} else {
pg.editor.Placeholder = "Andika code yako hapa..."
pg.editor.Placeholder = "Write vint code here..."
}

pg.editor.Prompt = "┃ "
Expand All @@ -234,12 +234,8 @@ func (pg playground) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
pg.output = viewport.New(msg.Width/2, msg.Height/3-4)
pg.output.Style = lipgloss.NewStyle().PaddingLeft(3)
var output string
if pg.language == "en" {

output = "Your code output will be displayed here..." + strings.Repeat(" ", msg.Width-6)
} else {
output = "Matokeo hapa..." + strings.Repeat(" ", msg.Width-6)
}
output = "Your code output will be displayed here..." + strings.Repeat(" ", msg.Width-6)

pg.output.SetContent(output)

// documentation
Expand Down
14 changes: 12 additions & 2 deletions repl/repl.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func Start() {
d.executor,
completer,
prompt.OptionPrefix(PROMPT),
prompt.OptionTitle("vint Programming Language"),
prompt.OptionTitle("Vint Programming Language"),
)

p.Run()
Expand All @@ -68,7 +68,17 @@ type dummy struct {

func (d *dummy) executor(in string) {
if strings.TrimSpace(in) == "exit()" {
fmt.Println(lipgloss.NewStyle().Render("\n🔥🅺🅰🆁🅸🅱🆄 🆃🅴🅽🅰 🔥"))
style := lipgloss.NewStyle().
Foreground(lipgloss.Color("#FFD700")). // Gold text
Background(lipgloss.Color("#282C34")). // Dark background
Bold(true).
Padding(1, 2).
Margin(1).
Border(lipgloss.DoubleBorder()).
BorderForeground(lipgloss.Color("#FF4500")) // Bright orange border

message := style.Render("\n🔥 Thank you for using Vint! Goodbye and happy coding! 🔥")
fmt.Println(message)
os.Exit(0)
}
l := lexer.New(in)
Expand Down
1 change: 1 addition & 0 deletions vintLang/example.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Hello, Vint!
2 changes: 1 addition & 1 deletion vintLang/os.vint
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@ lines = os.readLines("example.txt")
print(lines) // Outputs: ["Hello", "World"]

// Delete a file
os.deleteFile("example.txt")
//os.deleteFile("example.txt")

172 changes: 151 additions & 21 deletions website/README.md
Original file line number Diff line number Diff line change
@@ -1,36 +1,166 @@
This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://nextjs.org/docs/app/api-reference/cli/create-next-app).
# VintLang Installation Guide

## Getting Started
## Installing vintLang on Linux

First, run the development server:
You can install **vintLang** on your Linux computer using the following steps. This guide will walk you through downloading, extracting, and confirming the installation.

### Step 1: Download the vintLang Binary

First, download the binary release of vintLang for Linux using the following `curl` command:

```bash
curl -O -L https://github.com/ekilie/vint-lang/releases/download/0.1.0/vintLang_linux_amd64_v0.1.2.tar.gz
```

### Step 2: Extract the Binary to a Global Location

Once the download is complete, extract the file and place the binary in a directory that is globally available (`/usr/local/bin` is typically used for this purpose):

```bash
npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun dev
sudo tar -C /usr/local/bin -xzvf vintLang_linux_amd64_v0.1.2.tar.gz
```

This will unpack the binary and make the `vintLang` command available to all users on your system.

### Step 3: Confirm the Installation

To verify that **vintLang** has been installed correctly, run the following command to check its version:

```bash
vint -v
```

If the installation was successful, this command will output the version of **vintLang** that was installed.

---



### How to Install `vintLang`:
1. Open your terminal.
2. Run the `curl` command to download the `vintLang` binary.
3. Extract the downloaded archive to a globally accessible directory (`/usr/local/bin`).
4. Confirm the installation by checking the version with `vint -v`.

This guide should be easy to follow for installing `vintLang` on Linux!

Now you can start using **vintLang** on your Linux system!


## Sample Code

Here are some sample code snippets that show how to use **vintLang**. More examples are located in the `./vintLang` folder of the codebase.

### Example 1: String Splitting and Printing

```vint
// Importing modules
import net // Importing networking module for HTTP operations
import time // Importing time module to work with date and time
// Main logic to split and print characters of a string
let name = "VintLang"
s = name.split("")
for i in s {
print(i)
}
```

### Example 2: Type Conversion and Conditional Statements

```vint
// Demonstrating type conversion and conditional statements
age = "10"
convert(age, "INTEGER") // Convert age string to integer
print(type(age)) // Uncomment to check the type of ageInInt
// Conditional statements to compare the age variable
if (age == 20) {
print(age)
} else if (age == 10) {
print("Age is " + age)
} else {
print((age == "20"))
}
```

Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
### Example 3: Working with Height Variable

```vint
// Working with height variable
height = "6.0" // Height in feet
print("My name is " + name)
You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.
// Define a function to print details
let printDetails = func(name, age, height) {
print("My name is " + name + ", I am " + age + " years old, and my height is " + height + " feet.")
}
This project uses [`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts) to automatically optimize and load [Geist](https://vercel.com/font), a new font family for Vercel.
// Calling the printDetails function with initial values
printDetails(name, age, height)
## Learn More
// Update height and call the function again
height = "7"
printDetails(name, age, height)
```

### Example 4: Time-Related Operations

To learn more about Next.js, take a look at the following resources:
```vint
// Print the current timestamp
print(time.now())
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
// Function to greet a user based on the time of the day
let greet = func(nameParam) {
let currentTime = time.now() // Get the current time
print(currentTime) // Print the current time
if (true) { // Placeholder condition, modify for actual logic
print("Good morning, " + nameParam + "!")
} else {
print("Good evening, " + nameParam + "!")
}
}
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome!
// Time-related operations
year = 2024
print("Is", year, "Leap year:", time.isLeapYear(year))
print(time.format(time.now(), "02-01-2006 15:04:05"))
print(time.add(time.now(), "1h"))
print(time.subtract(time.now(), "2h30m45s"))
## Deploy on Vercel
// Call the greet function with a sample name
greet("John")
```

### Example 5: Networking with HTTP GET Request

```vint
// Example of a GET request using the net module
let res = net.get("https://tachera.com")
print(res)
```

### Example 6: Built-in Functions and Output

```vint
// Built-in functions
print(type(123)) // Print the type of an integer
let a = "123" // Initialize a string variable
convert(a, "INTEGER") // Convert the string to an integer
type(a)
print(a) // Check the type of the variable
print("Hello", "World") // Print multiple values
write("Hello World") // Write a string (useful in returning output)
```

### Step 4: Run the Sample Code

Once you have the sample code files saved, you can run them using the following command:

```bash
vint <filename>.vint
```

The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
Replace `<filename>` with the actual name of the file you want to run (e.g., `hello.vint`, `fibonacci.vint`, etc.).

Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details.
---

0 comments on commit e126c82

Please sign in to comment.