Instance methods
azu_project?
Check if current directory is an Azu project
Sourcebinary_name
Get binary name from shard.yml targets
Used by serve command to determine what to run
Sourcebuild_template_context(name : String, attributes : Hash(String, String) = {} of String => String, options : Hash(String, String) = {} of String => String) : Hash(String, String | Array(String) | Hash(String, String))
Build template context hash with common variables
Sourcecamel_case(str : String) : String
Convert string to camelCase
"my_class" => "myClass"
Sourcecheck_crystal_version
Check if current Crystal version meets requirements
Sourcecheck_shard_version(shard_name : String, required_version : String) : Bool
Check if shard version is compatible
Sourcecommand_exists?(command : String) : Bool
Check if command exists in PATH
Sourcecompare_versions(v1 : String, v2 : String) : Int32
Compare semantic versions
Returns -1 if v1 < v2, 0 if equal, 1 if v1 > v2
Sourcecrystal_file?(path : String) : Bool
Check if a file is a Crystal source file
Sourcedependency_version(shard_name : String) : String | Nil
Get dependency version from shard.yml
Sourcedetect_schema_info
Detect schema name from database configuration
Returns tuple of {schema_name, schema_symbol}
Matches CQL schema patterns like: BlogDB = CQL::Schema.define(...) or CQL::Schema.build(...)
Sourceenforce_crystal_version!
Check Crystal version and exit if incompatible
Sourceensure_directory(path : String)
Ensure directory exists, create if not
Sourcefile_basename(path : String) : String
Get file basename without extension
Sourcefile_extension(path : String) : String
Sourcegenerate_timestamp
Generate timestamp for migrations (YYYYMMDDHHmmSS format)
Sourcegenerate_unique_timestamp
Generate timestamp with microseconds for unique IDs
Sourcehas_dependency?(shard_name : String) : Bool
Check if a shard dependency exists in shard.yml
Sourcehas_shard_yml?
Check if shard.yml exists
Sourceindent(text : String, spaces : Int32 = 2) : String
Indent text by specified spaces
Sourcekebab_case(str : String) : String
Convert string to kebab-case
"MyClass" => "my-class"
Sourceparse_migration_timestamp(filename : String) : String | Nil
Parse migration timestamp from filename
"20240101120000_create_users.cr" => "20240101120000"
Sourcepascal_case(str : String) : String
Convert string to PascalCase
"my_class" => "MyClass"
Sourcepluralize(word : String) : String
Pluralize a word (simple implementation)
Handles common cases, may not be perfect for all words
Sourceproject_authors
Get project authors from shard.yml
Sourceproject_description
Get project description from shard.yml
Sourceproject_module_name
Get project module name from shard.yml
Returns PascalCase module name (e.g., "MyProject")
Sourceproject_name
Get project name from shard.yml
Returns project name or "app" as fallback
Sourceproject_version
Get project version from shard.yml
Sourcereserved_keyword?(name : String) : Bool
Check if string is a reserved Crystal keyword
Sourcerun_command(command : String, args : Array(String) = [] of String) : NamedTuple(success: Bool, output: String, error: String)
Run shell command and capture output
Sourcesafe_identifier(name : String) : String | Nil
Validate and sanitize user input for use as identifier
Returns sanitized name or nil if invalid
Use this when you need a guaranteed valid identifier
Sourcesafe_read_file(path : String) : String | Nil
Safely read file with error handling
Sourcesanitize_database_url(url : String) : String
Sanitize database URL for safe logging
Sourcesanitize_filename(name : String) : String
Sanitize user input for use as file/directory name
More restrictive than identifier - prevents path traversal
This is CRITICAL for security
Sourcesanitize_hash_for_logging(hash : Hash) : Hash
Sanitize hash/options for logging (removes sensitive keys)
Sourcesanitize_identifier(name : String) : String
Sanitize user input for use as Crystal identifier
Removes/replaces invalid characters, ensures valid start
This is critical for security - prevents code injection
Sourcesanitize_log_message(message : String) : String
Sanitize log messages to remove sensitive information
CRITICAL for security - prevents password/token leaks in logs
Sourcesanitize_path(path : String, base_dir : String = ".") : String | Nil
Sanitize path - prevents directory traversal attacks
CRITICAL for security when dealing with user-provided paths
Sourcesanitize_path_component(component : String) : String | Nil
Validate and sanitize path component
Use this for user-provided directory/file names in paths
Sourceschema_name
Get schema name from project
Sourcescreaming_snake_case(str : String) : String
Convert string to SCREAMING_SNAKE_CASE
"myClass" => "MY_CLASS"
Sourcesingularize(word : String) : String
Singularize a word (simple implementation)
Sourcesnake_case(str : String) : String
Convert string to snake_case
"MyClass" => "my_class"
Sourcesystem_info
Get system information for debugging
Sourcetemplate_file?(path : String) : Bool
Check if a file is a template file
Sourcevalid_class_name?(name : String) : Bool
Validate Crystal class/module name
Sourcevalid_identifier?(name : String) : Bool
Check if string is a valid Crystal identifier
Sourcewrap_text(text : String, width : Int32 = 80) : String
Wrap text at specified width
Source