<feed xmlns='http://www.w3.org/2005/Atom'>
<title>mutt-alias-auto-add/src/main.rs, branch v0.0.1</title>
<subtitle>A display filter for Mutt to automatically add aliases for emails that you read</subtitle>
<link rel='alternate' type='text/html' href='https://git.teddywing.com/mutt-alias-auto-add/'/>
<entry>
<title>Add a documentation comment to our crate</title>
<updated>2016-04-24T10:13:23+00:00</updated>
<author>
<name>Teddy Wing</name>
</author>
<published>2016-04-24T10:13:23+00:00</published>
<link rel='alternate' type='text/html' href='https://git.teddywing.com/mutt-alias-auto-add/commit/?id=15759804bd3be99fc6374ee993038440267fdfb5'/>
<id>15759804bd3be99fc6374ee993038440267fdfb5</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>main: Change `unwrap` to `expect`</title>
<updated>2016-04-24T09:48:05+00:00</updated>
<author>
<name>Teddy Wing</name>
</author>
<published>2016-04-24T09:48:05+00:00</published>
<link rel='alternate' type='text/html' href='https://git.teddywing.com/mutt-alias-auto-add/commit/?id=b11af1eccb5116b8901dd999f48210ce955ea9b7'/>
<id>b11af1eccb5116b8901dd999f48210ce955ea9b7</id>
<content type='text'>
Give us a better error message if a failure ever happens here. Was
inspired by my experience in 2d1f7031f03194fbceffc15b1d6376abea243e22,
where the `unwrap` calls gave no useful information.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Give us a better error message if a failure ever happens here. Was
inspired by my experience in 2d1f7031f03194fbceffc15b1d6376abea243e22,
where the `unwrap` calls gave no useful information.
</pre>
</div>
</content>
</entry>
<entry>
<title>Move `Alias` to separate alias module</title>
<updated>2016-04-24T09:40:45+00:00</updated>
<author>
<name>Teddy Wing</name>
</author>
<published>2016-04-24T09:40:45+00:00</published>
<link rel='alternate' type='text/html' href='https://git.teddywing.com/mutt-alias-auto-add/commit/?id=afc01ecb67dd978879d423866d33ac0c526151f4'/>
<id>afc01ecb67dd978879d423866d33ac0c526151f4</id>
<content type='text'>
Take all of our Alias code, functions, errors, etc. and move them into
their own module. This removes some clutter from our `main.rs` file and
makes things better organised. Now all the alias code lives in its own
dedicated place.

Update our test file imports to match this change.

Updates to alias code:

* Reordered imports alphabetically
* Made `Alias` public
* Made `AliasSearchError` public
* Made all methods on `Alias` public
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Take all of our Alias code, functions, errors, etc. and move them into
their own module. This removes some clutter from our `main.rs` file and
makes things better organised. Now all the alias code lives in its own
dedicated place.

Update our test file imports to match this change.

Updates to alias code:

* Reordered imports alphabetically
* Made `Alias` public
* Made `AliasSearchError` public
* Made all methods on `Alias` public
</pre>
</div>
</content>
</entry>
<entry>
<title>Move `write_alias` function to `Alias#write_to_file`</title>
<updated>2016-04-24T09:17:19+00:00</updated>
<author>
<name>Teddy Wing</name>
</author>
<published>2016-04-24T09:17:19+00:00</published>
<link rel='alternate' type='text/html' href='https://git.teddywing.com/mutt-alias-auto-add/commit/?id=2d1f7031f03194fbceffc15b1d6376abea243e22'/>
<id>2d1f7031f03194fbceffc15b1d6376abea243e22</id>
<content type='text'>
Expand the responsibility of `Alias#write_to_file` so that it performs
what it used to do plus all of what `write_alias` did.

This allows us to consolidate the functionality into a single method,
and move it into the `Alias` implementation.

The change required some modification to our `write_to_file` test:

* Create our test alias as mutable
* Write a new alias to the test file based on our test alias but with a
  different email. This allows the `write_to_file` method to work
  without erroring with an `AliasSearchError::NotFound`.
* Needed to `derive(Clone)` on `Alias` in order to be able to easily
  clone it into the new near-duplicate alias.
* Change our `unwrap()` calls to `expect()` to make it easier to see
  where exactly we panicked. Otherwise I didn't really have any way of
  knowing.
* Add some comments for clarity
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Expand the responsibility of `Alias#write_to_file` so that it performs
what it used to do plus all of what `write_alias` did.

This allows us to consolidate the functionality into a single method,
and move it into the `Alias` implementation.

The change required some modification to our `write_to_file` test:

* Create our test alias as mutable
* Write a new alias to the test file based on our test alias but with a
  different email. This allows the `write_to_file` method to work
  without erroring with an `AliasSearchError::NotFound`.
* Needed to `derive(Clone)` on `Alias` in order to be able to easily
  clone it into the new near-duplicate alias.
* Change our `unwrap()` calls to `expect()` to make it easier to see
  where exactly we panicked. Otherwise I didn't really have any way of
  knowing.
* Add some comments for clarity
</pre>
</div>
</content>
</entry>
<entry>
<title>Move `find_alias_in_file` function to `Alias#find_in_file`</title>
<updated>2016-04-24T08:43:00+00:00</updated>
<author>
<name>Teddy Wing</name>
</author>
<published>2016-04-24T08:43:00+00:00</published>
<link rel='alternate' type='text/html' href='https://git.teddywing.com/mutt-alias-auto-add/commit/?id=c67fdff0c3cda883b5bf577988e1c555931969cf'/>
<id>c67fdff0c3cda883b5bf577988e1c555931969cf</id>
<content type='text'>
Makes more sense for this function to live in a method on `Alias`
because it operates directly on an alias.

Refactor our tests and code to support this new organisation.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Makes more sense for this function to live in a method on `Alias`
because it operates directly on an alias.

Refactor our tests and code to support this new organisation.
</pre>
</div>
</content>
</entry>
<entry>
<title>Remove dependency on 'getopts'</title>
<updated>2016-04-23T06:48:18+00:00</updated>
<author>
<name>Teddy Wing</name>
</author>
<published>2016-04-23T06:48:18+00:00</published>
<link rel='alternate' type='text/html' href='https://git.teddywing.com/mutt-alias-auto-add/commit/?id=ad9ac4ec473ee23f6ca58c24fc33b1cb70520b83'/>
<id>ad9ac4ec473ee23f6ca58c24fc33b1cb70520b83</id>
<content type='text'>
As described in 0b12b2bae1130746ed49cc3c7a2daa819ede1b58, we don't need
to depend on 'getopts' because we don't have any command line options,
just a single required argument.

Rewrite our code to factor out getopts and assume that the first
argument to our program is an alias file path.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
As described in 0b12b2bae1130746ed49cc3c7a2daa819ede1b58, we don't need
to depend on 'getopts' because we don't have any command line options,
just a single required argument.

Rewrite our code to factor out getopts and assume that the first
argument to our program is an alias file path.
</pre>
</div>
</content>
</entry>
<entry>
<title>Specify alias file as a command line argument</title>
<updated>2016-04-23T06:18:14+00:00</updated>
<author>
<name>Teddy Wing</name>
</author>
<published>2016-04-23T06:18:14+00:00</published>
<link rel='alternate' type='text/html' href='https://git.teddywing.com/mutt-alias-auto-add/commit/?id=0b12b2bae1130746ed49cc3c7a2daa819ede1b58'/>
<id>0b12b2bae1130746ed49cc3c7a2daa819ede1b58</id>
<content type='text'>
* Add a dependency on 'getopts'
* Remove the hard-coded "testaliases" file used previously.
* write_alias: Update to include a `file` attribute that can reference
  an arbitrary file
* find_alias_in_file: Change the `file` parameter to be a Path reference
  instead of a string so that it can be called correctly from
  `write_alias`. Also because it matches the File module's signature.

Originally I planned to make the file argument available under a `-f`
command-line option. Later I decided instead to make it a required
argument, so it made more sense not to prefix it with an option flag.
Since I no longer need command line options—just the first argument—I
realised that I could get rid of the `getopts` dependency and use
`std::env::args`. Will do this in a later commit.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
* Add a dependency on 'getopts'
* Remove the hard-coded "testaliases" file used previously.
* write_alias: Update to include a `file` attribute that can reference
  an arbitrary file
* find_alias_in_file: Change the `file` parameter to be a Path reference
  instead of a string so that it can be called correctly from
  `write_alias`. Also because it matches the File module's signature.

Originally I planned to make the file argument available under a `-f`
command-line option. Later I decided instead to make it a required
argument, so it made more sense not to prefix it with an option flag.
Since I no longer need command line options—just the first argument—I
realised that I could get rid of the `getopts` dependency and use
`std::env::args`. Will do this in a later commit.
</pre>
</div>
</content>
</entry>
<entry>
<title>Add descriptions to `AliasSearchError` `fmt::Display`</title>
<updated>2016-04-22T23:09:43+00:00</updated>
<author>
<name>Teddy Wing</name>
</author>
<published>2016-04-22T23:03:04+00:00</published>
<link rel='alternate' type='text/html' href='https://git.teddywing.com/mutt-alias-auto-add/commit/?id=b9f6915d1e92f77c002f05a1371941dd3e3dcb95'/>
<id>b9f6915d1e92f77c002f05a1371941dd3e3dcb95</id>
<content type='text'>
Use the descriptions from our `error::Error` implementation. To do so
needed to `use std::error::Error`.

Change those `write!` calls to `writeln!` also so that we get decent
output on the command line.

We now output errors from `AliasSearchError::{NotFound, EmailExists}` to
STDERR for better error reporting.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Use the descriptions from our `error::Error` implementation. To do so
needed to `use std::error::Error`.

Change those `write!` calls to `writeln!` also so that we get decent
output on the command line.

We now output errors from `AliasSearchError::{NotFound, EmailExists}` to
STDERR for better error reporting.
</pre>
</div>
</content>
</entry>
<entry>
<title>Write alias errors to STDERR instead of panicking</title>
<updated>2016-04-22T21:20:27+00:00</updated>
<author>
<name>Teddy Wing</name>
</author>
<published>2016-04-22T21:20:27+00:00</published>
<link rel='alternate' type='text/html' href='https://git.teddywing.com/mutt-alias-auto-add/commit/?id=4535477b09ff1753cdc83e3c44585ad393a5c716'/>
<id>4535477b09ff1753cdc83e3c44585ad393a5c716</id>
<content type='text'>
We use an `.ok()` call on the result of the write so that we can ignore
these errors. I think we shouldn't really worry too much about not being
to write to STDERR, and instead try to print out the full email message
as best we can.

In order to write the error (`e.to_string()`), we needed to implement
`fmt::Display` on `AliasSearchError`. While I was at it also implemented
the `error::Error` trait.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
We use an `.ok()` call on the result of the write so that we can ignore
these errors. I think we shouldn't really worry too much about not being
to write to STDERR, and instead try to print out the full email message
as best we can.

In order to write the error (`e.to_string()`), we needed to implement
`fmt::Display` on `AliasSearchError`. While I was at it also implemented
the `error::Error` trait.
</pre>
</div>
</content>
</entry>
<entry>
<title>main: Simplify the STDOUT writer</title>
<updated>2016-04-22T20:24:43+00:00</updated>
<author>
<name>Teddy Wing</name>
</author>
<published>2016-04-22T20:24:43+00:00</published>
<link rel='alternate' type='text/html' href='https://git.teddywing.com/mutt-alias-auto-add/commit/?id=7d71a6392836880d88bab27481b32e6b63b77c6e'/>
<id>7d71a6392836880d88bab27481b32e6b63b77c6e</id>
<content type='text'>
I wrote it the way I originally did because I wanted to be more
explicit, but I don't think that was right. Doing it this way because it
makes the code much simpler. Also found out there's a `writeln!` macro
which I probably should have used instead of manually adding a newline
before.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
I wrote it the way I originally did because I wanted to be more
explicit, but I don't think that was right. Doing it this way because it
makes the code much simpler. Also found out there's a `writeln!` macro
which I probably should have used instead of manually adding a newline
before.
</pre>
</div>
</content>
</entry>
</feed>
