Skip to content

Commit 3efc76c

Browse files
none
1 parent 62cc285 commit 3efc76c

File tree

8 files changed

+126
-0
lines changed

8 files changed

+126
-0
lines changed

.cargo/config.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[alias]

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/target
2+
Cargo.lock
3+
.DS_Store

.scripts/git.sh

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
2+
#!/bin/bash
3+
4+
# Check if the current directory is a Git repository
5+
git rev-parse --is-inside-work-tree > /dev/null 2>&1
6+
if [ $? -ne 0 ]; then
7+
echo "Error: The current directory is not a Git repository."
8+
exit 1
9+
fi
10+
11+
# Get the current Git branch
12+
current_branch=$(git rev-parse --abbrev-ref HEAD)
13+
14+
# Prompt the user for a commit message
15+
read -p "Enter a commit message: " commit_message
16+
17+
# Check if there are any changes to commit
18+
if [ -z "$(git status --porcelain)" ]; then
19+
echo "Nothing to commit."
20+
exit 0
21+
fi
22+
23+
# Add all changes to the staging area
24+
git add .
25+
26+
# Create a new commit
27+
git commit -m "$commit_message"
28+
29+
# Check if a remote repository is configured
30+
if [ -z "$(git remote get-url origin)" ]; then
31+
read -p "No remote repository configured. Would you like to set one up? (y/n) " configure_remote
32+
if [ "$configure_remote" == "y" ]; then
33+
read -p "Enter the remote repository URL: " remote_url
34+
git remote add origin "$remote_url"
35+
else
36+
echo "Skipping remote repository setup."
37+
exit 0
38+
fi
39+
fi
40+
41+
# Push the changes to the remote repository
42+
read -p "Push changes to the remote repository? (y/n) " push_confirm
43+
if [ "$push_confirm" == "y" ]; then
44+
git push -u origin "$current_branch"
45+
else
46+
echo "Changes not pushed to the remote repository."
47+
fi

Cargo.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[workspace]
2+
resolver = "2"
3+
members = [ "crates/*"]
4+
5+
[workspace.package]
6+
edition = "2021"
7+
version = "0.0.1"
8+
repository = "https://github.com/centlax/stone"

crates/cli/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/target

crates/cli/Cargo.toml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[package]
2+
name = "cli"
3+
edition.workspace = true
4+
version.workspace = true
5+
repository.workspace = true
6+
default-run = "cli"
7+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
8+
9+
[dependencies]

crates/cli/src/content/mod.rs

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
use std::fs;
2+
use std::path::{Path, PathBuf};
3+
4+
#[allow(dead_code)]
5+
enum Object {
6+
Table,
7+
View,
8+
Function,
9+
Procedure,
10+
}
11+
12+
#[derive(Debug)]
13+
pub struct Task {
14+
pub stmt: String, // SQL statement
15+
}
16+
17+
#[derive(Debug)]
18+
pub struct Block {
19+
pub tasks: Vec<Task>,
20+
}
21+
22+
#[derive(Debug)]
23+
pub struct File {
24+
pub blocks: Vec<Block>,
25+
pub path: PathBuf,
26+
}
27+
28+
#[derive(Debug)]
29+
pub struct SQL {
30+
pub files: Vec<File>,
31+
pub folder: String,
32+
}
33+
34+
impl SQL {
35+
pub fn new() -> Self {
36+
// Define the path for the .maris directory
37+
let stone_dir = Path::new(".stone");
38+
39+
// Check if the directory exists, and create it if it does not
40+
if !stone_dir.exists() {
41+
if let Err(e) = fs::create_dir(stone_dir) {
42+
eprintln!("Failed to create directory '.stone': {}", e);
43+
// Optionally handle the error or propagate it
44+
}
45+
}
46+
47+
Self {
48+
files: Vec::new(),
49+
folder: ".stone".to_string()
50+
}
51+
}
52+
}

crates/cli/src/main.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pub mod content;
2+
fn main() {
3+
println!("Hello, world!");
4+
content::SQL::new();
5+
}

0 commit comments

Comments
 (0)