Swift Rewrite #1

Closed
wants to merge 17 commits into
from

Conversation

Projects
None yet
2 participants
@justincampbell
Owner

justincampbell commented Apr 12, 2016

No description provided.

@justincampbell

This comment has been minimized.

Show comment
Hide comment
@justincampbell

justincampbell Apr 12, 2016

Owner

Random thoughts:

  • Should IconOuput return all 3 (ok, warn, error) emoji, or only the relevant emoji?
  • Instead of arguments, maybe this should take a format string, something like %p() %n(q) and this could also support a time or date format, such as%t(hh:mm:ss).
Owner

justincampbell commented Apr 12, 2016

Random thoughts:

  • Should IconOuput return all 3 (ok, warn, error) emoji, or only the relevant emoji?
  • Instead of arguments, maybe this should take a format string, something like %p() %n(q) and this could also support a time or date format, such as%t(hh:mm:ss).
main.swift
+ case .Ok:
+ if !options.quiet {
+ stdout.append(output.okIcon)
+ if let suffix = output.suffix { stdout.append(suffix) }

This comment has been minimized.

@justincampbell

justincampbell Apr 12, 2016

Owner

Would be nice to remove the duplication for this line:

if let suffix = output.suffix { stdout.append(suffix) }
@justincampbell

justincampbell Apr 12, 2016

Owner

Would be nice to remove the duplication for this line:

if let suffix = output.suffix { stdout.append(suffix) }
@apbendi

This comment has been minimized.

Show comment
Hide comment
@apbendi

apbendi Apr 18, 2016

Collaborator

hey @justincampbell, took a look at this- maybe you can spec out a little, and/or write tests, for what results you're going for? Is the goal just to reproduce the exact functions of the bash version? I thought you'd mentioned wanting the q argument to do something different based on where it was positioned, or no?

Collaborator

apbendi commented Apr 18, 2016

hey @justincampbell, took a look at this- maybe you can spec out a little, and/or write tests, for what results you're going for? Is the goal just to reproduce the exact functions of the bash version? I thought you'd mentioned wanting the q argument to do something different based on where it was positioned, or no?

@justincampbell

This comment has been minimized.

Show comment
Hide comment
@justincampbell

justincampbell Apr 18, 2016

Owner

@apbendi Yeah I think a better format long term is to have a format string. I don't know what that should look like. It should support arbitrary strings (spaces) in between elements, and also support quieting each individually. So, if I wanted power always shown, and network quiet, and I wanted a space before, between, and after:

tmux-status-bar " {p} {nq} "

But maybe there's already and existing library/pattern that would do something close enough to that. In Ruby:

tmux-status-bar " #{power} #{quiet(network)} "

It would be kinda gross evaling that, but it would work. What do you think?

Owner

justincampbell commented Apr 18, 2016

@apbendi Yeah I think a better format long term is to have a format string. I don't know what that should look like. It should support arbitrary strings (spaces) in between elements, and also support quieting each individually. So, if I wanted power always shown, and network quiet, and I wanted a space before, between, and after:

tmux-status-bar " {p} {nq} "

But maybe there's already and existing library/pattern that would do something close enough to that. In Ruby:

tmux-status-bar " #{power} #{quiet(network)} "

It would be kinda gross evaling that, but it would work. What do you think?

@apbendi

This comment has been minimized.

Show comment
Hide comment
@apbendi

apbendi Apr 18, 2016

Collaborator

The eval approach is definitely not going to work in Swift, being statically typed. Leaving aside the ability to format it arbitrarily, you could perhaps used cased arguments to allow varying quietness on each parameter (i.e. -pN would be power, quiet network).

That said, if the grammar has two keywords, it should be pretty straightforward to write a simple parser, and that could be fun too!

Collaborator

apbendi commented Apr 18, 2016

The eval approach is definitely not going to work in Swift, being statically typed. Leaving aside the ability to format it arbitrarily, you could perhaps used cased arguments to allow varying quietness on each parameter (i.e. -pN would be power, quiet network).

That said, if the grammar has two keywords, it should be pretty straightforward to write a simple parser, and that could be fun too!

@justincampbell

This comment has been minimized.

Show comment
Hide comment
@justincampbell

justincampbell Apr 19, 2016

Owner

@apbendi Yeah, flags are definitely easier, and we can just decide on single space in between, and let the user wrap in spaces if needed. I think lowercase/uppsercase args is a good solution for quiet-ness.

Owner

justincampbell commented Apr 19, 2016

@apbendi Yeah, flags are definitely easier, and we can just decide on single space in between, and let the user wrap in spaces if needed. I think lowercase/uppsercase args is a good solution for quiet-ness.

@justincampbell

This comment has been minimized.

Show comment
Hide comment
@justincampbell

justincampbell Apr 19, 2016

Owner

@apbendi Also, take another look, I just pushed my WIP from last week. It's probably worth starting an Xcode project from scratch and using this code as a proof of concept.

Owner

justincampbell commented Apr 19, 2016

@apbendi Also, take another look, I just pushed my WIP from last week. It's probably worth starting an Xcode project from scratch and using this code as a proof of concept.

@justincampbell

This comment has been minimized.

Show comment
Hide comment
@justincampbell

justincampbell Apr 23, 2016

Owner

I started an Xcode project, and pushed it to master: https://github.com/justincampbell/terminal-status-bar

Owner

justincampbell commented Apr 23, 2016

I started an Xcode project, and pushed it to master: https://github.com/justincampbell/terminal-status-bar

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment