Files
metabuilder/packages/package_validator/seed/scripts/cli.lua
JohnDoe6345789 9d27207fbc Refactor package validation and quick guide modules
- Simplified structure validation by re-exporting functions from structure_config and validate_structure modules for better maintainability.
- Consolidated validation logic in validate.lua, delegating to validate_package module for clearer orchestration.
- Introduced new quick guide functionalities including step management (add, remove, update, reset ordering) and media handling (thumbnail and video URL validation).
- Added utility functions for URL validation and step creation, enhancing the quick guide's usability.
- Established type definitions for steps and media states to improve code clarity and type safety.
- Enhanced schema editor with new field and relation definitions, providing a more robust structure for database schema management.
2025-12-30 11:17:40 +00:00

73 lines
1.6 KiB
Lua

--- CLI tool facade for validating packages
--- Usage: lua cli.lua <package_name> [options]
---@module cli
local validate = require("validate")
local parse_args = require("parse_args")
local print_help = require("print_help")
local output_json = require("output_json")
local output_human = require("output_human")
---@class CLI
local M = {}
M.parse_args = parse_args
M.print_help = print_help
M.output_json = output_json
M.output_human = output_human
--- Main entry point
---@param args string[] Command line arguments
function M.run(args)
local options = parse_args(args)
if options.show_help then
print_help()
os.exit(0)
end
if not options.package_name then
print("Error: Package name is required")
print("Use --help for usage information")
os.exit(2)
end
-- Construct package path
local package_path = "packages/" .. options.package_name .. "/seed"
-- Check if package exists
local metadata_file = io.open(package_path .. "/metadata.json", "r")
if not metadata_file then
print("Error: Package '" .. options.package_name .. "' not found")
os.exit(2)
end
metadata_file:close()
-- Validate package
local results = validate.validate_package(package_path, {
skipStructure = options.skipStructure,
skipLua = options.skipLua
})
-- Output results
if options.json_output then
output_json(results)
else
output_human(results, options.verbose)
end
-- Exit with appropriate code
if results.valid then
os.exit(0)
else
os.exit(1)
end
end
return M
-- If run directly, execute main
if arg then
M.run(arg)
end