• Stars
    star
    292
  • Rank 142,126 (Top 3 %)
  • Language
    Swift
  • License
    MIT License
  • Created about 5 years ago
  • Updated almost 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

🤖🔜🤯 Stop writing boilerplate code yourself. Let hackman do it for you via the command line.

 text

HackMan

Swift Package Manager compatible License MIT

HackMan is a simple tool for generating boilerplate code directly via the command line.

Let hackman do the boring work and save some time. Hackman is heavily inspired by the rails command.

Installation

Clone and build

git clone [email protected]:Cosmo/HackMan.git
cd HackMan
swift build -c release

Add hackman executable to your PATH.

PATH=$PATH:$(pwd)/.build/release

or make it persistent

For zsh Users (default on macOS Catalina)

echo "export PATH=\"\$PATH:$(pwd)/.build/release\"" >> ~/.zshrc

For bash Users (default on macOS Mojave)

echo "export PATH=\"\$PATH:$(pwd)/.build/release\"" >> ~/.bash_profile

Usage

New Project

# Create new project directory including a "project.yml" for xcodegen
hackman new APP_NAME

# Change into your project directory
cd APP_NAME

Generators

Run these generators inside of your project directory.

# Create an AppDelegate
hackman generate app_delegate

Options
  --coordinator, -c
    Adds coordinator support

  --force, -f
    Force override existing files
# Create an empty AssetCatalog
hackman generate asset_catalog

Options
  --force, -f
    Force override existing files
# Create a LaunchScreen-Storyboard
hackman generate launch_screen

Options
  --force, -f
    Force override existing files
# Create a ReusableView protocol and useful extensions for UICollectionViews and UITableViews
hackman generate reusable_view

Options
  --force, -f
    Force override existing files
# Create a Coordinator protocol
hackman generate coordinator

Options
  --force, -f
    Force override existing files
# Create a MainCoordinator
hackman generate coordinator_main NAME NAME …

Options
  --force, -f
    Force override existing files

  --include=NAME,NAME,…
    Include ViewControllers that were not generated via scaffold.
    Names must be separated with commas. Spaces between names are not allowed.
# Create a Child-Coordinator with the given name
hackman generate coordinator_child NAME

Options
  --force, -f
    Force override existing files
# Create a Model with the given name and properties
hackman generate model NAME [PROPERTY[:TYPE] PROPERTY[:TYPE]] …

Options
  --force, -f
    Force override existing files
# Create a UIViewController-Subclass with the given name
hackman generate view_controller NAME

Options
  --coordinator, -c
    Adds coordinator support

  --force, -f
    Force override existing files
# Create a ViewControllerCollection (UIViewController-Subclass with a UICollectionView) and UICollectionViewDataSource
hackman generate view_controller_collection NAME [PROPERTY[:TYPE] PROPERTY[:TYPE]] …

Options
  --coordinator, -c
    Adds coordinator support

  --force, -f
    Force override existing files
# Create a UICollectionViewCell-Subclass with the given namen and properties as UILabels
hackman generate collection_view_cell NAME [PROPERTY[:TYPE] PROPERTY[:TYPE]] …

Options
  --force, -f
    Force override existing files
# Create a ViewControllerTable (UIViewController-Subclass with a UITableView) and UITableViewDataSource
hackman generate view_controller_table NAME [PROPERTY[:TYPE] PROPERTY[:TYPE]] …

Options
  --coordinator, -c
    Adds coordinator support

  --force, -f
    Force override existing files
# Create a UITableViewCell-Subclass with the given namen and properties as UILabels
hackman generate table_view_cell NAME [PROPERTY[:TYPE] PROPERTY[:TYPE]] …

Options
  --force, -f
    Force override existing files
# Create a ViewControllerDetail (UIViewController-Subclass) with the given namen and properties as UILabels
hackman generate view_controller_detail NAME [PROPERTY[:TYPE] PROPERTY[:TYPE]] …

Options
  --coordinator, -c
    Adds coordinator support

  --force, -f
    Force override existing files
# Create a UIViewController-Subclass with a UIWebView
hackman generate view_controller_web

Options
  --coordinator, -c
    Adds coordinator support

  --force, -f
    Force override existing files
# Create a UIViewController-Subclass with entry points for legal documents
hackman generate view_controller_information

Options
  --coordinator, -c
    Adds coordinator support
  
  --force, -f
    Force override existing files
# Create Model, UICollectionView/UITableView Extensions, UIViewController with UICollectionView/UITableView, ViewControllerDetail, ChildCoordinator, Coordinator Protocol and ReusableView Protocol
hackman generate scaffold NAME [PROPERTY[:TYPE] PROPERTY[:TYPE]] …

# By default, the scaffold will be UICollectionView based.
# In order to create UITableView based scaffolds, pass the --view=table at the end.
# Like so:
hackman generate scaffold song title:string year:int --view=table

Options
  --coordinator, -c
    Adds coordinator support
    
  --force, -f
    Force override existing files

You can also write hackman g instead of hackman generate.

Properties

When creating scaffolds, models, controllers you can also specify multiple fields to be generated automatically

hackman g scaffold author name:string birthday:date

This commands creates among other things a struct of type Author with the following properties.

    let name: String
    let birthday: Date

You can also reference to your custom types.

hackman g scaffold Article title:string body:string published_at:date author:author

This will generate the following properties inside of the Article model.

    let title: String
    let body: String
    let publishedAt: Date
    let author: Author

If you omit the property type, hackman assumes you want a property of type String.

hackman g scaffold article title body published_at:date author:author

An example of a fully working app

hackman new MusicApp
cd MusicApp
hackman g app_delegate --coordinator
hackman g asset_catalog
hackman g launch_screen
hackman g scaffold artist name --coordinator
hackman g scaffold song title year:int --coordinator
hackman g scaffold album name uuid artist:artist created_at:date updated_at:date --coordinator
hackman g view_controller_information --coordinator
hackman g coordinator_main song artist album --include=information
xcodegen
open MusicApp.xcodeproj

Demo

Demo

Requirements

  • Xcode 10
  • Swift 5

Todos

  • Easier setup
  • Easy support for custom generators
  • Add help (-h / --help)
  • SwiftUI based templates
  • Generator for localization

Contact

License

HackMan is released under the MIT License.

More Repositories

1

TinyConsole

📱💬🚦 TinyConsole is a micro-console that can help you log and display information inside an iOS application, where having a connection to a development computer is not possible.
Swift
1,955
star
2

OpenSwiftUI

WIP — OpenSwiftUI is an OpenSource implementation of Apple's SwiftUI DSL.
Swift
1,382
star
3

Clippy

📎💬🎉 Clippy from Microsoft Office is back and runs on macOS! Written in Swift.
Swift
741
star
4

SwiftUIEmbedded

WIP — SwiftUIEmbedded is an implementation of SwiftUI (based on OpenSwiftUI) for embedded and Linux devices.
Swift
111
star
5

BinaryKit

💾🔍🧮 BinaryKit helps you to break down binary data into bits and bytes, easily access specific parts and write data to binary.
Swift
110
star
6

awesome-embedded-swift

⚡️🛠🧰 A curated list for Embedded and Low-Level development in the Swift programming language.
Swift
69
star
7

GrammaticalNumber

1️⃣🔜🔢 Turns singular words to the plural and vice-versa in Swift.
Swift
35
star
8

SwiftUIEmbedded-Demo

WIP — SwiftUIEmbedded — Demo for Linux
Swift
31
star
9

ISO8859

🌍⏩📄 Convert ISO8859 1-16 Encoded Text to String in Swift. Supports iOS, tvOS, watchOS and macOS.
Swift
18
star
10

Nodes

🌲🌿🌳 Nodes is a class protocol for tree data structures with multiple children. Written in Swift.
Swift
17
star
11

StringCase

👇👆🐍 Converts String to lowerCamelCase, UpperCamelCase and snake_case. Tested and written in Swift.
Swift
16
star
12

ShotPlan

A command line tool that calls your Xcode Test Plan and creates screenshots of your app automatically.
Swift
11
star
13

TransportStream

🎬📺🎞 MPEG-TS (Transport Stream) Tools: Demultiplexer, CRC32, Program Specific Information (PMT PAT, NIT, CAT). Written in Swift.
Swift
10
star
14

bashtv

Hackathon Project — Watch public television in your terminal. No browser needed.
Swift
8
star
15

awesome-swift-platforms

A curated list of Swift on different platforms.
Swift
4
star
16

Pixels

WIP — Pixels is a low level graphics library written in Swift.
Swift
4
star
17

News-Sightseeing

Sophisticated-location-aware-news.
C#
3
star
18

bashtv-service

C#
2
star
19

PSVR_api

C#
2
star
20

ToThePoint

Hackathon Project — Jump right to the interesting parts of a video. Project at mediahackday.
JavaScript
2
star
21

JSKit

A quick and dirty attempt to recreate UIKit in JavaScript
JavaScript
2
star
22

Isometric

JavaScript
1
star
23

SpriteMap

SpriteMap helps you to extract sprites out of a sprite map. Written in Swift.
Swift
1
star
24

spotify-places

Spotify places enables social playlists for bars based on the users favorite songs.
C#
1
star
25

FeedCollectionViewLayout

[WIP] 📱📐 Customizable UICollectionLayout for single and multi-column feeds.
Swift
1
star
26

Note

This is for debugging and reference only. Document Based + ReferenceFileDocument + UndoManager + Commands Example
Swift
1
star