Folder Structure CLI is a command-line tool written in Go that creates a folder structure based on a JSON file input. This tool is useful for quickly setting up project structures, organizing files, or replicating directory layouts.
- Create folders and files based on a JSON structure
- Simple command-line interface
- Recursive creation of nested structures
- Error handling and reporting
- Go 1.23.1 or later
- Clone the repository:
git clone https://github.com/ondrovicfolder-structure-cli.git
- Navigate to the project directory:
cd folder-structure-cli
- Build the application:
go build
./folder-structure-cli create [json_file_path] [output_path]
[json_file_path]
: Path to the JSON file describing the folder structure[output_path]
: Path where the folder structure will be created
./folder-structure-cli create structure.json ./output
To display the version of the CLI:
./folder-structure-cli -v
or
./folder-structure-cli --version
The JSON file should describe the folder structure. Use null
for files and nested objects for folders.
Example structure.json
:
{
"folder1": {
"subfolder1": {
"file1.txt": null,
"file2.txt": null
},
"subfolder2": {}
},
"folder2": {
"file3.txt": null
},
"file4.txt": null
}
This will create:
output/
├── folder1/
│ ├── subfolder1/
│ │ ├── file1.txt
│ │ └── file2.txt
│ └── subfolder2/
├── folder2/
│ └── file3.txt
└── file4.txt
The CLI will print error messages for:
- Invalid JSON files
- File read/write errors
- Invalid folder structures
folder-structure-cli/
├── cmd/
│ ├── root.go
│ └── create.go
├── main.go
└── go.mod
main.go
: Entry point of the applicationcmd/root.go
: Defines the root command and version flagcmd/create.go
: Implements thecreate
command
To add a new command:
- Create a new file in the
cmd/
directory (e.g.,cmd/newcommand.go
) - Define the command structure and functionality
- Add the command to the root command in the
init()
function
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.