Skip to content

Commit

Permalink
added CLI, refactor to seperate UI and logic slightly better
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobsjo committed Oct 1, 2023
1 parent 902e783 commit bf29ae7
Show file tree
Hide file tree
Showing 22 changed files with 1,699 additions and 319 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ jobs:
uses: actions/upload-pages-artifact@v1
with:
# Upload dist repository
path: './dist'
path: './dist-web'
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v1
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
dist
dist-api
dist-web
node_modules
public/vanilla_datapacks

Expand Down
35 changes: 35 additions & 0 deletions bin/snowcapped-cli.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/env node

import fs from 'fs';
import { BiomeBuilder, Exporter } from '../dist-api/snowcapped.mjs'
import { program } from 'commander';

program
.argument('<input>', 'Input snowcapped file')
.option('-d, --dimension <file>', 'Ouput file for dimension file')
.option('-c, --biome-colors <file>', 'Output file for biome-colors.json file')
.usage('<input> [-d <dimension output>] [-c <biome_colors output>]')

program.parse()

const biomeBuilder = new BiomeBuilder()

const inputJson = JSON.parse(fs.readFileSync(program.args[0], 'utf8'))
biomeBuilder.loadJSON(inputJson)

const exporter = new Exporter(biomeBuilder)

const options = program.opts()

console.log(options)

if (options.dimension){
fs.writeFileSync(options.dimension, JSON.stringify(exporter.getDimensionJSON(), null, 2), {encoding: "utf8"})
}

if (options.biomeColors){
if (!biomeBuilder.exportBiomeColors){
console.warn("Warning: Biome Color export is disabled by in Snowcapped settings. Exporing anyways.")
}
fs.writeFileSync(options.biomeColors, JSON.stringify(exporter.getBiomeColorJson(), null, 2))
}
Loading

0 comments on commit bf29ae7

Please sign in to comment.