Permalink
Browse files

change --clean be the default and add --bash to duplicate old method

  • Loading branch information...
1 parent b50bf32 commit 884c22f0c69a1454de8e66ccc983b64283e4aef2 @gregkh committed May 21, 2008
Showing with 24 additions and 18 deletions.
  1. +4 −4 bti.1
  2. +12 −10 bti.c
  3. +8 −4 bti.xml
View
@@ -14,7 +14,7 @@
bti - send a tweet to twitter.com from the command line
.SH "SYNOPSIS"
.HP 4
-\fBbti\fR [\fB\-\-account\ account\fR] [\fB\-\-password\ password\fR] [\fB\-\-clean\fR] [\fB\-\-debug\fR] [\fB\-\-version\fR] [\fB\-\-help\fR]
+\fBbti\fR [\fB\-\-account\ account\fR] [\fB\-\-password\ password\fR] [\fB\-\-bash\fR] [\fB\-\-debug\fR] [\fB\-\-version\fR] [\fB\-\-help\fR]
.SH "DESCRIPTION"
.PP
bti sends a twitter message to twitter\.com\.
@@ -35,9 +35,9 @@ Specify the password of your twitter\.com account\.
Print a whole bunch of debugging messages to stdout\.
.RE
.PP
-\fB\-\-clean\fR
+\fB\-\-bash\fR
.RS 4
-Don\'t put the working directory and the \'$\' in the twitter message\.
+Add the working directory and a \'$\' in the twitter message to help specify it is coming from a command line\. Don\'t put the working directory and the \'$\' in the twitter message\.
.RE
.PP
\fB\-\-version\fR
@@ -58,7 +58,7 @@ It\'s primary focus is to allow you to log everything that you type into a bash
To hook bti up to your bash shell, export the following variable:
.PP
-PROMPT_COMMAND=\'history 1 | sed \-e "s/^\es*[0\-9]*\es*//" | bti\'
+PROMPT_COMMAND=\'history 1 | sed \-e "s/^\es*[0\-9]*\es*//" | bti \-\-bash\'
.PP
This example assumes that you have the
\fI~/\.bti\fR
View
@@ -44,7 +44,7 @@ struct session {
char *password;
char *account;
char *tweet;
- int clean;
+ int bash;
};
struct bti_curl_buffer {
@@ -61,7 +61,7 @@ static void display_help(void)
fprintf(stdout, "options are:\n");
fprintf(stdout, " --account accountname\n");
fprintf(stdout, " --password password\n");
- fprintf(stdout, " --clean\n");
+ fprintf(stdout, " --bash\n");
fprintf(stdout, " --debug\n");
fprintf(stdout, " --version\n");
fprintf(stdout, " --help\n");
@@ -299,7 +299,7 @@ int main(int argc, char *argv[], char *envp[])
{ "account", 1, NULL, 'a' },
{ "password", 1, NULL, 'p' },
{ "help", 0, NULL, 'h' },
- { "clean", 0, NULL, 'c' },
+ { "bash", 0, NULL, 'b' },
{ "version", 0, NULL, 'v' },
{ }
};
@@ -342,8 +342,8 @@ int main(int argc, char *argv[], char *envp[])
session->password = strdup(optarg);
dbg("password = %s\n", session->password);
break;
- case 'c':
- session->clean = 1;
+ case 'b':
+ session->bash= 1;
break;
case 'h':
display_help();
@@ -367,6 +367,7 @@ int main(int argc, char *argv[], char *envp[])
session->password = get_string_from_stdin();
}
+ /* get the current working directory basename */
if (strcmp(pwd, home) == 0)
dir = "~";
else {
@@ -377,19 +378,20 @@ int main(int argc, char *argv[], char *envp[])
dir = "?";
}
- /* Add the "PWD $ " to the start of the tweet to show it is
- * coming from a shell unless --clean is specified. */
tweet = get_string_from_stdin();
if (strlen(tweet) == 0) {
dbg("no tweet?\n");
return -1;
}
session->tweet = zalloc(strlen(tweet) + strlen(dir) + 10);
- if (session->clean)
- sprintf(session->tweet, "%s", tweet);
- else
+
+ /* if --bash is specified, add the "PWD $ " to
+ * the start of the tweet. */
+ if (session->bash)
sprintf(session->tweet, "%s $ %s", dir, tweet);
+ else
+ sprintf(session->tweet, "%s", tweet);
free(tweet);
dbg("account = %s\n", session->account);
View
@@ -28,7 +28,7 @@
<command>bti</command>
<arg><option>--account account</option></arg>
<arg><option>--password password</option></arg>
- <arg><option>--clean</option></arg>
+ <arg><option>--bash</option></arg>
<arg><option>--debug</option></arg>
<arg><option>--version</option></arg>
<arg><option>--help</option></arg>
@@ -65,9 +65,13 @@
</listitem>
</varlistentry>
<varlistentry>
- <term><option>--clean</option></term>
+ <term><option>--bash</option></term>
<listitem>
- <para>Don't put the working directory and the '$' in the twitter message.</para>
+ <para>
+ Add the working directory and a '$' in the twitter message to
+ help specify it is coming from a command line. Don't put the
+ working directory and the '$' in the twitter message.
+ </para>
</listitem>
</varlistentry>
<varlistentry>
@@ -105,7 +109,7 @@
To hook bti up to your bash shell, export the following variable:
</para>
<para>
- <literal> PROMPT_COMMAND='history 1 | sed -e "s/^\s*[0-9]*\s*//" | bti'</literal>
+ <literal> PROMPT_COMMAND='history 1 | sed -e "s/^\s*[0-9]*\s*//" | bti --bash'</literal>
</para>
<para>
This example assumes that you have the

0 comments on commit 884c22f

Please sign in to comment.