Skip to content

Commit 6842cb0

Browse files
committed
Merge branch 'master' of github.com:Stoozy/SML
2 parents 46c5a8e + 15de807 commit 6842cb0

File tree

13 files changed

+580
-37345
lines changed

13 files changed

+580
-37345
lines changed

.github/workflows/rust.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Rust
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
9+
env:
10+
CARGO_TERM_COLOR: always
11+
12+
jobs:
13+
build:
14+
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- uses: actions/checkout@v2
19+
- name: Build
20+
run: cargo build --verbose
21+
- name: Run tests
22+
run: cargo test --verbose

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
/target
22
*.org
3+
*.log

LICENSE

Lines changed: 339 additions & 0 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
### SML
2+
3+
![Build](https://github.com/Stoozy/SML/actions/workflows/rust.yml/badge.svg)
4+
[![License: GPL v2](https://img.shields.io/badge/License-GPL%20v2-blue.svg)](https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html)
5+
6+
Welcome to stoozys minecraft launcher!
7+
8+
## About
9+
10+
This is a CLI program that allows you to install and launch curseforge modpacks. Currently it only supports forge only but soon it will have fabric and vanilla support.
11+
12+
## Motivation
13+
14+
I am working on this project purely for the learning experience, there are working minecraft modded launchers out there already, such as MultiMC. However, this project should benefit those who don't want a fully featured GUI program and would rather do things in a shell.
15+
16+
17+
## Usage
18+
19+
```
20+
SML 0.1.0
21+
Stoozy <mahinsemail@gmail.com>
22+
A Minecraft Modded Launcher Command Line Interface
23+
24+
USAGE:
25+
sml [FLAGS] [OPTIONS]
26+
27+
FLAGS:
28+
-a, --auth Log in through mojang
29+
-c, --config configures instance
30+
-h, --help Prints help information
31+
--list Lists all SML instances
32+
-V, --version Prints version information
33+
34+
OPTIONS:
35+
-i, --install <ID> Searches for project in curseforge with given ID and installs it
36+
--launch <ID> Launches instance with specific ID
37+
-r <ID> Removes instance with the ID provided
38+
```
39+
40+
## Forge Installer
41+
42+
This launcher uses a wrapper class around the forge installer written by @xfl03 in order to automate the installation. See https://github.com/xfl03/ForgeInstallerHeadless
43+
44+
## What doesn't work right now
45+
46+
Fabric and Vanilla are not supported yet.
47+
Forge packs with version less than 1.13.
48+
49+
50+
## Issues
51+
52+
If you encounter any issues, feel free to open an (issue)[https://github.com/Stoozy/SML/issues, "issue"] on github
53+

forge-1.16.5-36.0.10-installer.jar.log

Lines changed: 0 additions & 18566 deletions
This file was deleted.

releases/linux-pre-alpha-0.1.0.tar.gz

3.67 MB
Binary file not shown.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
3+
cp -v ./sml /usr/bin
4+
if [ $? -eq 0 ]; then
5+
echo SML Successfully Installed!
6+
else
7+
echo This script must be run with permissions
8+
fi

releases/linux-pre-alpha-0.1.0/sml

11.5 MB
Binary file not shown.

src/forge-1.16.5-36.1.0-installer.jar.log

Lines changed: 0 additions & 18686 deletions
This file was deleted.

src/invoker.rs

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -98,20 +98,6 @@ impl Invoker {
9898
}
9999

100100
pub fn invoke(&mut self) {
101-
//let mut inovker_path = self.binpath.clone();
102-
//// pop bin/
103-
//invoker_path.pop();
104-
//// push filename
105-
//invoker_path.push_str("sml_invoker.json");
106-
//let mut invoker_file = OpenOptions::new()
107-
// .read(true)
108-
// .write(false)
109-
// .open(invoker_path)
110-
// .expect("Unable to open sml invoker file");
111-
112-
//let mut invoker_json = serde_json::from_reader(invoker_file);
113-
//let binarg = format!("-Djava.library.path=\"{}\"", self.binpath.display());
114-
115101
let mut cps = "\"".to_string();
116102
for cp in &self.classpaths {
117103
cps.push_str(format!("{};", cp.display()).as_str());
@@ -128,20 +114,6 @@ impl Invoker {
128114
.cwd(cwd)
129115
.popen()
130116
.unwrap();
131-
132-
//let cmd = Command::new("java")
133-
// .arg("-cp")
134-
// .arg(cps)
135-
// .arg(self.main.clone())
136-
// .arg(self.args.clone())
137-
// .current_dir(cwd);
138-
139-
//cmd
140-
// .output()
141-
// .expect("Failed to launch instance");
142-
143-
//let adir = cmd.get_current_dir().unwrap();
144-
//println!("{}", adir.display())
145117
}
146118
}
147119

src/main.rs

Lines changed: 72 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
/*
2+
* SML - A minecraft modded launcher CLI
3+
*
4+
*Copyright (C) 2021 Stoozy
5+
*This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
6+
*This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
7+
*You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
8+
*
9+
*/
10+
111
extern crate clap;
212
extern crate ftp;
313

@@ -11,28 +21,26 @@ pub mod invoker;
1121
pub mod util;
1222

1323
use clap::*;
14-
use std::{
15-
fs::{self},
16-
ops::Deref,
17-
};
1824

1925
use std::io::Write;
2026

2127
use crate::ima::InstanceManager;
2228
use crate::invoker::Invoker;
29+
use std::fs::{self, OpenOptions};
2330

2431
use ansi_term::Colour::*;
2532

2633
fn main() -> () {
27-
let mut ima = InstanceManager::new(util::get_instances_path().unwrap());
34+
let mut instances_path = util::get_instances_path().unwrap();
35+
let mut ima = InstanceManager::new(instances_path.clone());
2836

29-
let mut user_path = std::env::current_exe().unwrap();
30-
user_path.pop(); // get rid of executable
37+
let mut user_path = instances_path;
38+
user_path.pop(); // get rid of instances dir
3139
user_path.push("userinfo.json");
3240

3341
// create new app
3442
let app = App::new("SML")
35-
.version("1.0")
43+
.version("0.1.0")
3644
.author("Stoozy <mahinsemail@gmail.com>")
3745
.about("A Minecraft Modded Launcher Command Line Interface")
3846
.arg(
@@ -56,11 +64,18 @@ fn main() -> () {
5664
.takes_value(true),
5765
)
5866
.arg(
59-
Arg::with_name("id")
67+
Arg::with_name("config")
68+
.short("c")
69+
.long("config")
70+
.help("configures instance")
71+
.takes_value(false),
72+
)
73+
.arg(
74+
Arg::with_name("install")
6075
.short("i")
61-
.long("id")
76+
.long("install")
6277
.value_name("ID")
63-
.help("Searches for project in curseforge with given ID")
78+
.help("Searches for project in curseforge with given ID and installs it")
6479
.takes_value(true),
6580
)
6681
.arg(
@@ -72,10 +87,53 @@ fn main() -> () {
7287
)
7388
.get_matches();
7489

90+
if app.is_present("list") {
91+
ima.display_list();
92+
return ();
93+
}
94+
95+
if app.is_present("config") {
96+
ima.display_list();
97+
println!("Please enter which instance you would like to configure: ");
98+
99+
let instances = ima.get_list();
100+
let id = util::get_u64().expect("Invalid number");
101+
let invoker_file_path = &instances[id as usize];
102+
103+
dbg!(invoker_file_path.clone());
104+
let invoker_file = OpenOptions::new()
105+
.read(true)
106+
.write(true)
107+
.open(invoker_file_path.clone())
108+
.expect("Unable to open sml invoker file");
109+
110+
let mut invoker_json: serde_json::Value =
111+
serde_json::from_reader(invoker_file).expect("Invalid sml invoker json file");
112+
113+
let mut new_custom_args = String::new();
114+
115+
println!("Enter custom java flags: ");
116+
117+
std::io::stdin()
118+
.read_line(&mut new_custom_args)
119+
.expect("Unable to get user input");
120+
121+
// no need for newline characters
122+
let len = new_custom_args.trim_end_matches(&['\r', '\n'][..]).len();
123+
new_custom_args.truncate(len);
124+
125+
invoker_json["custom_args"] = serde_json::Value::String(new_custom_args);
126+
127+
std::fs::write(invoker_file_path, invoker_json.to_string())
128+
.expect("Unable to write to sml invoker file");
129+
130+
println!("{}", Green.paint("Configuration complete!"))
131+
}
132+
75133
match app.value_of("remove") {
76134
Some(id) => {
77135
let id_num = id.parse::<u64>().expect("Not a valid id");
78-
let mut instances = ima.get_list();
136+
let instances = ima.get_list();
79137
let invoker_path = &instances[id_num as usize];
80138

81139
let mut cwd = invoker_path.clone();
@@ -109,11 +167,6 @@ fn main() -> () {
109167
None => (),
110168
}
111169

112-
if app.is_present("list") {
113-
ima.display_list();
114-
return ();
115-
}
116-
117170
// authentication
118171
if app.is_present("authenticate") {
119172
let user = auth::handle_auth().expect("Failed authentication");
@@ -125,11 +178,11 @@ fn main() -> () {
125178
fs::write(user_path.clone(), user_data.as_bytes()).expect("Couldn't save user info");
126179
}
127180

128-
match app.value_of("id") {
181+
match app.value_of("install") {
129182
Some(id) => {
130183
// if there is no userinfo, stop the setup process
131184
if !user_path.exists() {
132-
println!("Please authenticate first!");
185+
println!("{}", Red.paint("Please authenticate first!"));
133186
return;
134187
}
135188
sml::forge_setup(ima, id.parse::<u64>().expect("Not a valid id"), user_path);

0 commit comments

Comments
 (0)